samvermette / SVPullToRefresh

Give pull-to-refresh & infinite scrolling to any UIScrollView with 1 line of code.
http://samvermette.com/314
MIT License
4.82k stars 1.09k forks source link

In iOS7, the contentInsets of UISrollView can't be restored when using SVPullToRefresh in a UIViewController which is embedded in a UINavigationController #262

Open kudocc opened 9 years ago

kudocc commented 9 years ago

I found the reason, that is the default value of automaticallyAdjustsScrollViewInsets in UIViewController is YES so the UIViewController will adjust the contentInsets of UIScrollView or UITableView. However in viewDidLoad method, contentInsets is (0, 0, 0, 0), which means adjusting doesn't happen here, but in viewDidLayoutSubviews method, contentInsets is (64, 0, 0, 0).

I looked into the source code and found that in addPullToRefreshWithActionHandler: method, it keep the original contentInsets and try to restore it when finish refreshing. So I recommend to use addPullToRefreshWithActionHandler: in viewDidLayoutSubviews.

skyline75489 commented 8 years ago

I also noticed this. And putting addPullToRefreshWithActionHandler in viewDidLayoutSubviews indeed works.