2016-02-29 162 views
0

當我自定義tableHeaderView,我reloadDataviewWillAppear後,表查看contentOffset.y將被改變。TableView yOffset改變後reloadData

請幫助我..


我日誌的tableView contentOffset時,我會調用reloadData, 這是日誌:

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)); 

In viewDidLoad我已設置:

self.edgesForExtendedLayout = UIRectEdgeNone; 
self.automaticallyAdjustsScrollViewInsets = NO; 
+0

有什麼實際工作中的問題? –

+0

你能更具體嗎? UITableView或UITableViewController是否在任何UINavigationController或UITabBarController中加載? –

+0

發佈一些代碼,告訴我們你已經嘗試了什麼,並清楚地解釋我們的問題。我們很樂意爲您提供幫助。 – iPeter

回答

0

嘗試添加以下代碼viewDidLoad

在斯威夫特:

self.automaticallyAdjustsScrollViewInsets = false 

在Objective-C

self.automaticallyAdjustsScrollViewInsets = NO; 
+0

不適合我。 –

0

我終於解決了通過刪除以下代碼問題:

- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath

0

這個固定爲我(thanks to rshinich)同樣的問題:

self.tableView.estimatedRowHeight = 0; 
self.tableView.estimatedSectionHeaderHeight = 0; 
self.tableView.estimatedSectionFooterHeight = 0;