This is my code:
func pullToRefresh() {
if Reachability().connectionStatus() == .Online {
self.homewebview.reload()
} else {
self.refreshControl.endRefreshing()
let alert = UIAlertView(title: "No Internet connection", message: "Please check your Internet connection.", delegate: nil, cancelButtonTitle: "Okay")
alert.show()
}
}
When internet connection is not available and the user pulls to refresh an alert should be shown and the animation should stop. That works great on iOS 9. But on iOS 10 Beta 2 the animation doesn't disappear. The user have to pull up to make it disappear. It that an iOS 10 bug or am I doing something wrong?
P.S. I already tried to add assert(NSThread.isMainThread()) but that didn't help.
I've just encountered this issue and for those using UIAlertController, you may wish to try something similar to the following:
[self presentViewController:alert animated:TRUE completion:^{
[self.refreshControl endRefreshing];
}];
This enables the loading spinner to disappear in the background as soon as the alert has been displayed.
Swift Equivalent:
present(alert, animated: true) {
self.refreshControl.endRefreshing()
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With