I have a UITableViewController as the root view controller in a UINavigationController, which is in turn one of the view controllers in a UITabBarController. All hooked up in Storyboard.
I've configured the UIRefreshControl for my table in Storyboard as well, and normally it looks like it should when pulling:
However, if I switch between my other tabs once or twice, it looks like this:
It's not spinning or anything, just stuck "full", and it stays that way until I pull fully and trigger a refresh.
Any ideas or suggestions appreciate.
I could not get the call to endRefreshing to work before the navigation happened so I approached the problem from the other end and on viewWillAppear I check if the tableView contentOffset is a negative number bring the tableView back to 0.
I want some points and like Albert solution but not his style.
I was able to solve this issue by placing the following piece of code in viewWillDisappear
If the above code is placed in viewWillAppear then spinner will animate and dismiss within a fraction of seconds, in either of the cases the issue will be solved but however, in users point of view the spinner should not be visible so, it's better to place it in viewWillDisappear.
I have a collectionView, and I did set it's contentInset.
When pushing some ViewControllers, then press home button, and go back and pop back, the UIRefreshControl is always on the top.
Finally I use this code temporarily avoid it. (Ugly but stops it always shows on top)
To sum up and provide a complete solution.
The problem:
If UIRefreshControl is animating during screen transition, it will stay visible but will not be animating. Video https://vid.me/Bkb7
Also, if pull to refresh animation was started but not completed, and then transition was performed, UIRefreshControl will be hidden but stuck. Video https://vid.me/Bkb7
Solution:
Start UIRefreshControl animation on viewWillAppear and end it on viewDidDisappear. Save the state of refresh process to know when to show UIRefreshControl.
Bellow is the whole solution that also handles the proper animation and simple pull to refresh animation.
Add to UITableView or subclass
Initialization:
Superview event handlers:
UIRefreshControl animation handler:
Add
to begining of the refresh call.
Result video https://vid.me/LyuI
user2009606 was almost right, I fixed it by calling
On
The refreshControl now behaves properly after switching tabs, independent of its state.