SVPullToRefresh
SVPullToRefresh copied to clipboard
Have a navigation bar, refresh will make the first message is hidden under the navigation bar
I got the same problem recently. You need to add action handler in - viewDidAppear
method or after, as you can get correct scroll view contentInset
then (after iOS7).
- addPullToRefreshWithActionHandler
method record current scrollview contentInset
as originalTopInset
, originalBottomInset
and reset to that contentInset after - stopAnimating
.
(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;
}