3

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

demonstrative image

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?

Community
  • 1
  • 1
Praneeth Wanigasekera
  • 916
  • 1
  • 10
  • 14

2 Answers2

2

After completed loading You have to stop the refreshing

[tableView.refreshControl endRefreshing]

Hope its useful for you..:)

moosa0709
  • 476
  • 3
  • 12
  • I do call endRefreshing in the startRefresh selector, and it works fine every time, except in the scenario mentioned above. When you say after completed loading, do you mean every time the view loads? i.e. in viewWillAppear for example? – Praneeth Wanigasekera Sep 24 '14 at 03:52
  • 1
    Call in viewDidLoad and try – moosa0709 Sep 24 '14 at 03:57
  • http://stackoverflow.com/questions/13085662/pull-to-refresh-in-uicollectionviewcontroller?lq=1 – moosa0709 Sep 24 '14 at 04:00
  • http://stackoverflow.com/questions/14678727/uirefreshcontrol-on-uicollectionview-only-works-if-the-collection-fills-the-heig – moosa0709 Sep 24 '14 at 04:01
  • Also try in -(void)viewWillAppear:(BOOL)animated – moosa0709 Sep 24 '14 at 04:05
  • I added to both viewWillAppear and viewDidLoad and this did not have an impact on the problem I have. Thanks. – Praneeth Wanigasekera Sep 24 '14 at 09:57
  • This worked for me, 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): http://stackoverflow.com/questions/26130272/is-there-a-way-for-the-top-view-controller-in-ecslidingviewcontroller-to-know-wh – Praneeth Wanigasekera Oct 02 '14 at 22:58
0

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];
  }
}
Matt Bearson
  • 915
  • 7
  • 15