Reputation: 946
I have a UIRefreshControl connected to a UICollection that is defined this way for pull to refresh:
self.refreshControl = [[UIRefreshControl alloc] init];
[self.refreshControl addTarget:self action:@selector(startRefresh:)
self.collectionView.alwaysBounceVertical = YES;
[self.collectionView addSubview:self.refreshControl];
This works fine. However, whenever I move to a new view by either pushing a new view controller or displaying the sliding sidebar menu, and return to this view, the refresh control starts displaying the image for a control pulled all the way (i.e. it doesn't animate and shows the full circle). However, if I pull down fully and release, the refresh control returns to normal functionality. The control works fine, it just looks funky the first time you pull after navigating elsewhere.
I would love any feedback on what might be going wrong. Thanks!
This is what the image looks like when not working (note I am linking to an online image, this is not from my app so this doesn't show that the collectionview is being pulled down):
Posted solution below worked, but I had to do some extra work to figure out when my top view controller received focus from the sidebar menu that I was using (ECSlidingViewController): Is there a way for the Top View Controller in ECSlidingViewController to know when the sidebar menu has been dismissed?
Upvotes: 3
Views: 1115
Reputation: 1033
I had a slightly different issue but the symptoms were similar. This is what worked for me:
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
_refreshControl.hidden = YES;
}
- (void)viewDidLayoutSubviews {
[super viewDidLayoutSubviews];
if (_refreshControl.isRefreshing) {
[self.collectionView sendSubviewToBack:_refreshControl];
}
}
Upvotes: 0
Reputation: 476
After completed loading You have to stop the refreshing
[tableView.refreshControl endRefreshing]
Hope its useful for you..:)
Upvotes: 2