UIRefreshController animation error
I had this problem and tried every suggestion above (and others from similar threads).
What problem turned out to be in my case ... I didn't enable the update in the interface builder. I just added some code to create an update control and listen for the value changed event. It worked, but was "nervous" as others have described.
Enabling this in the interface builder fixed my problem. If you've tried everything else, check out your storyboard!
source to share
This works for me with Swift 2
if self.refreshControl.refreshing {
self.refreshControl.endRefreshing()
}
GlobalHelper.setTimeout(0.1, block: {
self.tableView.reloadData()
})
this is my timeout function:
static func setTimeout(delay:NSTimeInterval, block:()->Void) -> NSTimer {
return NSTimer.scheduledTimerWithTimeInterval(delay, target: NSBlockOperation(block: block), selector: #selector(NSOperation.main), userInfo: nil, repeats: false)
}
source to share
I faced this problem. For endRefreshing()
The documentation states:
If animation is also enabled, the control is hidden with animation.
I end up with the call in the UIView animation block and the transition is smooth:
UIView.animateWithDuration(0.5) {
self.refreshControl.endRefreshing()
}
source to share
In Swift 3 iOS 10 I got a similar approach as ibrahimyilmaz and here it is:
self.refreshControl.endRefreshing()
//Need to dispatch the alertView, otherwise, RefreshControl.endRefreshing() doesn't work.
let when = DispatchTime.now() + 1
DispatchQueue.main.asyncAfter(deadline: when) { [weak self] in
self?.showSettingAlertView()
}
At first I was sending endRefreshing as suggested by many threads, but it actually works the other way around.
Additional information: This code is executed at the: didChange: delegate location, not at viewDidLoad or viewWillAppear. Browse other topics. There seems to be an issue in the Apple SDK when trying to endRefreshing and showing the popup at the same time.
source to share