UIRefreshController animation error

When I call self.refreshControl.endRefreshing()

it binds the tableView to its original location as it should. How do I animate the animation so that it smoothly returns to its original location on endRefreshing()

?

+3


source to share


7 replies


For anyone else having this problem, you should call your method endRefreshing

before reloading the table data. Otherwise, when the table is updated, it will override the update and throw an error.



+6


source


try it



[CATransaction begin];
[CATransaction setCompletionBlock:^{
    // reload tableView after refresh control finish refresh animation
    [self.tableView reloadData];
}];

[self.refreshControl endRefreshing];
[CATransaction commit];

      

+7


source


// stop refreshing
[self.refreshControl endRefreshing];

// update tableview
[self.tableview performSelector:@selector(reloadData) withObject:nil afterDelay:.3]; 

      

+2


source


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!

Enable update in storyboard!

+1


source


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)
}

      

0


source


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()
}

      

0


source


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.

-1


source







All Articles