Reputation: 673
I'm trying to update my apps for iOS 8 and one strange issue that I can't figure out is that whenever I press a table view cell (on a grouped table view) and push another view controller on to the navigation controller, all the cells of the table view jump. It's sort of like they all reduce their height a little bit.
Consequently, when popping the navigation stack and coming back to the original table view screen, the cells jump again, this time they increase their height and going to back to how they were originally.
I have tried using a UITableViewController, doing my own table view management, not using explicity section heights, removing all custom header views and frames, basically anything I could think of.
It's happening on all the iOS 8 emulators and on actual devices runnings iOS 8 both iPhones and iPads.
Any suggestions will really help.
Edit: removed video
Upvotes: 17
Views: 4651
Reputation: 1
self.tableView.estimatedRowHeight=0;
self.tableView.estimatedSectionHeaderHeight=0;
self.tableView.estimatedSectionFooterHeight=0;
Upvotes: 0
Reputation: 3477
I solved the jumping problem with the Storyboard alone:
Upvotes: 0
Reputation: 3280
You can achieve self-sizing with this code:
implement together:
tableView.rowHeight = UITableViewAutomaticDimension;
tableView.estimatedRowHeight = CGFloatValue (initial estimated height);
in your storyboard, add the correct constraint on you cells.
Note: the jump issue will still show sometimes.
the exact solution for this jump issue is implementing the delegate method:
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return CGFloat;
}
Upvotes: -1
Reputation: 673
Alright, so if you're using the default UITableViewCell
s and setting custom fonts for the textLabel
and detailTextLabel
, make sure you either set rowHeight
for the table view or implement one of the UITableViewDelegate
methods for e.g. tableView:estimatedHeightForRowAtIndexPath:
The same code has worked fine on earlier versions of iOS, but needs fixing on iOS 8 for some reason.
Upvotes: 11
Reputation: 11751
I had the exact same problem! It seems like the iOS 8 SDK uses the estimatedRowHeight, after selecting a row, which then results in a wrong height for the whole tableview, which causes the jumping of the tableview itself.
Not setting the estimatedRowHeight property or implementing the delegate method will fix the jumping bug.
I have not found a clean solution to fix it yet.
Upvotes: 8