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

烂漫一生 提交于 2019-12-10 14:14:38

问题


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?


回答1:


Do it inside viewDidLoad method.




回答2:


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.



来源:https://stackoverflow.com/questions/21296028/ios-refresh-control-attempting-to-change-the-refresh-control-while-it-is-no

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!