Table View Cells jump when selected on iOS 8

前端 未结 5 790
隐瞒了意图╮
隐瞒了意图╮ 2020-12-15 06:36

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

相关标签:
5条回答
  • 2020-12-15 06:45

    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;
    
    }
    
    0 讨论(0)
  • 2020-12-15 06:48

    Alright, so if you're using the default UITableViewCells 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.

    0 讨论(0)
  • 2020-12-15 06:52
    self.tableView.estimatedRowHeight=0;
    self.tableView.estimatedSectionHeaderHeight=0;
    self.tableView.estimatedSectionFooterHeight=0;
    
    0 讨论(0)
  • 2020-12-15 06:53

    I solved the jumping problem with the Storyboard alone:

    1. TableView Row Height: automatic.
    2. TableView Estimate: my_value (e.g. 75)
    3. TableView Cell Row Height: my_value
    0 讨论(0)
  • 2020-12-15 07:08

    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.

    0 讨论(0)
提交回复
热议问题