How do I “hide” a UIRefreshControl?

前端 未结 12 955
醉梦人生
醉梦人生 2020-12-15 16:16

Occasionally my table view won\'t be connected to a service to refresh, and in that case, I don\'t want the UIRefreshControl to be present.

After I add it in viewDid

12条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-15 17:02

    You have several ways to do this. I think the best way is to do a check in the viewDidLoad method with:

    if (condition){
     //attach refreshControl
    }
    

    if this isn't possible the best way is put this code where you want to hide the refresh (I think in viewWillAppear method in if condition)

    //End refresh control
    [self.refreshControl endRefreshing];
    //Remove refresh control to superview
    [self.refreshControl removeFromSuperview];
    

提交回复
热议问题