1

I am having an issue with an UITableView.

I am displaying a collection of tracking records. After the user taps on a cell, a detail view controller is displayed with detailed data. My problem is after I call popViewControllerAnimated:YES from the Detail view controller, my table view is reseted and scrolls to the top position automatically.

I am not calling [myTable reloadData]; on viewWillAppear and I find this behavior kinda strange.

Does anyone have an idea what I might be missing here?

Any help or tip would be appreciated!

Thanks, Granit

Granit
  • 1,261
  • 6
  • 19
  • 35
  • try presenting the Detail ViewController instead of pushing. – iphondroid Aug 24 '15 at 13:52
  • [There's an iOS 8 issue with self-sizing](http://stackoverflow.com/a/26602948/4151918) that causes the tableView to "jump." The more inaccurate the estimated height, the more pronounced the effect. Using a better estimate will minimize the issue. –  Aug 24 '15 at 14:05
  • This solved my problem, thanks. Could you answer so I can accept your solution? @PetahChristian – Granit Aug 26 '15 at 09:19

2 Answers2

5

It's a known issue.

The more the estimatedRowHeight differs from the actual height, the more the table will jump when the push segue happens. The easiest workaround is to use a much better estimate.

1

if you don't call reloadData then either you re-add the table somewhere or you popped ViewController was reloaded because of some reason. Does ViewDidLoad called when you pop back?

How about storing the table scrolling state? (contentOffset)

Yaro
  • 1,222
  • 11
  • 15
  • Hi @Jaro i tried to scroll back to the stored scrolling state, but the table still is scrolling to top. – Granit Aug 24 '15 at 15:05
  • You have not just stored it but also restored it in viewWillAppear using [mainTableView setContentOffset:CGPointSomething animated:YES]; ? One more thing: I hope u are not calling [table setContentSize:..] somewhere after presenting table cuzz that will do the same effect. – Yaro Aug 25 '15 at 17:46
  • Seems that the issue with self-sizing caused the jump in the table view. Thanks for your comments :) – Granit Aug 26 '15 at 09:20