iOS - Refresh Control - "Attempting to change the refresh control while it is not idle is strongly discouraged and probably won't work properly."
Asked Answered
M

2

7

I cannot find many references to this warning anywhere. I have two view controllers that offer pull-to-refresh control. One is fine. The other produces the warning above. I copied the code from one to the other.

The code is as follows (PFUser refers to Parse.com):

[super viewDidAppear:animated];
    if ([PFUser currentUser]) {
        NSLog(@"who's the user: %@", [PFUser currentUser]);


        UIRefreshControl *refreshTable = [[UIRefreshControl alloc] init];
        refreshTable.attributedTitle = [[NSAttributedString alloc] initWithString:@"One sec... refreshing"];
        [refreshTable addTarget:self action:@selector(refresh:) forControlEvents:UIControlEventValueChanged];
        self.refreshControl = refreshTable;

    } else {

Has anyone else encountered this? and is there a work-around/fix?

Mcnulty answered 22/1, 2014 at 23:10 Comment(3)
How about doing it in viewDidLoad.Opal
You nailed it. Thank you. If you write it up as an answer, I'll mark it complete. Thank you very muchMcnulty
Glad it helped. I've written it as an answer.Opal
O
9

Do it inside viewDidLoad method.

Opal answered 23/1, 2014 at 5:16 Comment(0)
I
4

In my case, this warning popped up since I was doing collectionView.refreshControl = nil while refreshControl was animating. Calling refreshControl.endRefreshing() before doing that eliminated the warning.

Immature answered 16/10, 2017 at 18:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.