UITableViewController+KYSelfSizingPushFix

解决了iOS8中使用Self-Sizing Cell自动布局时,push时发生cell跳跃的bug


License
MIT
Install
pod try UITableViewController+KYSelfSizingPushFix

Documentation

KYSelfSizingPushFixCategory

CocoaPods Version License Platform

A UITableView Category for fixing the bug of 'Self-Sizing-Cell' when push to next ViewController the tableView position will change.

Installation

pod 'UITableViewController+KYSelfSizingPushFix', '~> 1.0.0'

How to use

Three Steps:

1.Add code in - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    ...

    if (![self ky_isEstimatedRowHeightInCache:indexPath]) {
        CGSize cellSize = [cell systemLayoutSizeFittingSize:CGSizeMake(self.view.frame.size.width, 0) withHorizontalFittingPriority:1000.0 verticalFittingPriority:50.0];
        [self ky_putEstimatedCellHeightToCache:indexPath height:cellSize.height];
    }

    ...

}

2.Implement estimatedHeightForRowAtIndexPath:

-(CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return [self ky_getEstimatedCellHeightFromCache:indexPath defaultHeight:250.0f];
}

3.Remember to use[self ky_tableViewReloadData]; rather than [self.tableView reloadData];

You're done!