Latest 1.0.0
Homepage https://github.com/KittenYang/KYSelfSizingPushFixCategory
License MIT
Platforms ios , requires ARC
Frameworks Foundation, UIKit
Authors

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!

Latest podspec

{
    "name": "UITableViewController+KYSelfSizingPushFix",
    "version": "1.0.0",
    "summary": "u89e3u51b3u4e86iOS8u4e2du4f7fu7528Self-Sizing Cellu81eau52a8u5e03u5c40u65f6uff0cpushu65f6u53d1u751fcellu8df3u8dc3u7684bug",
    "description": "                   u7ed9UITableViewControlleru589eu52a0u4e86u4e00u4e2aCategoryu3002u89e3u51b3u4e86iOS8u4e2du4f7fu7528Self-Sizing Cellu81eau52a8u5e03u5c40u65f6uff0cpushu65f6u53d1u751fcellu8df3u8dc3u7684bugn",
    "homepage": "https://github.com/KittenYang/KYSelfSizingPushFixCategory",
    "license": "MIT",
    "authors": {
        "KittenYang": "[email protected]"
    },
    "platforms": {
        "ios": null
    },
    "source": {
        "git": "https://github.com/KittenYang/KYSelfSizingPushFixCategory.git",
        "tag": "1.0.0"
    },
    "source_files": "UITableViewController+KYSelfSizingPushFix/*.{h,m}",
    "frameworks": [
        "Foundation",
        "UIKit"
    ],
    "requires_arc": true
}

Pin It on Pinterest

Share This