当我定制tableHeaderView
,在reloadData
的viewWillAppear
后,tableView contentOffset.y
将被更改。
请帮我..
当我调用reloadData
时,我已经记录了tableView contentOffset,这是日志:
2016-03-01 10:51:04:362 ~~[1474:387143] will-TableViewContentOffset: {0, -18}
2016-03-01 10:51:04:363 ~~[1474:387143] did-TableViewContentOffset: {0, -62}
这是我如何调用:
NHDLog(@"will-TableViewContentOffset: %@", NSStringFromCGPoint(self.tableView.
[self _reloadTableView];
NHDLog(@"did-TableViewContentOffset: %@", NSStringFromCGPoint(self.tableView.contentOffset));
在viewDidLoad
我设置:
self.edgesForExtendedLayout = UIRectEdgeNone;
self.automaticallyAdjustsScrollViewInsets = NO;
这为我解决了同样的问题(thanks to rshinich):
self.tableView.estimatedRowHeight = 0;
self.tableView.estimatedSectionHeaderHeight = 0;
self.tableView.estimatedSectionFooterHeight = 0;
尝试在viewDidLoad
中添加以下代码:
在Swift中:
self.automaticallyAdjustsScrollViewInsets = false
在Objective-C中
self.automaticallyAdjustsScrollViewInsets = NO;
我终于通过删除以下代码解决了这个问题:
- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath