UIRefreshControl iOS 6 xcode

前端 未结 3 1431
一个人的身影
一个人的身影 2020-12-12 22:32

Does anyone have a short example of how to implement the new UIRefreshControl into xcode. I have a UITableViewController which displays Tweets, wa

3条回答
  •  春和景丽
    2020-12-12 22:44

    You can also configure this in Interface Builder. Though the way it currently works, it only saves you a couple of lines of code.

    Select the TableViewController scene and in the Attributes Inspector, you'll find a drop down list option for "Refreshing." Set that to "Enabled." You'll notice in the View Controller Hierarchy that a "Refresh Control" has been added (you won't see anything visually added to the scene itself). What's odd is that after hooking up the Refresh Control to an IBAction (Value Change Event) the event doesn't seem to get triggered. I'm guessing that's a bug (?) but meanwhile, setting "Refreshing" to enabled creates the UIRefreshControl object and assigns it to the view controller's refreshControl property. With that done, you can add the event handling line to your viewDidLoad method:

    [self.refreshControl addTarget:self action:@selector(refreshView:) forControlEvents:UIControlEventValueChanged];
    

    In your refreshView: method, you can do some work and then stop the refresh animation:

    - (void)refreshView:(UIRefreshControl *)sender {
        // Do something...
        [sender endRefreshing];
    }
    

提交回复
热议问题