Open andi911 opened 9 years ago
(void)viewDidLoad {
UIEdgeInsets inset = UIEdgeInsetsMake(64, 0, 0, 0); //64 is navigation.height+20
self.tableView.contentInset = inset;
self.tableView.scrollIndicatorInsets = inset;
}
The workaround from @sinabs makes the position of the tableView correct AFTER the pullToRefresh is triggered, but the placement beforehand is still incorrect.
try a again this.
(void)viewDidLoad {
//UIEdgeInsets inset = UIEdgeInsetsMake(64, 0, 0, 0); //64 is navigation.height+20
//self.tableView.contentInset = inset;
//self.tableView.scrollIndicatorInsets = inset;
[self.navigationController.navigationBar setTranslucent:NO];
}
as liruqi said, I put action handler in - viewDidAppear, and it works fine~
this is my solution: in viewDidLoad add below codes and it woks fine
if ([self respondsToSelector:@selector(automaticallyAdjustsScrollViewInsets)]) {
self.automaticallyAdjustsScrollViewInsets = NO;
UIEdgeInsets insets = self.tableView.contentInset;
insets.top = self.navigationController.navigationBar.bottom;
self.tableView.contentInset = insets;
self.tableView.scrollIndicatorInsets = insets;
}
I got the same problem recently. You need to add action handler in
- viewDidAppear
method or after, as you can get correct scroll viewcontentInset
then (after iOS7).- addPullToRefreshWithActionHandler
method record current scrollviewcontentInset
asoriginalTopInset
,originalBottomInset
and reset to that contentInset after- stopAnimating
.