Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Refresh Control or Pull to refresh in iOS

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 485
    Comment on it

    Hi guys here's an example of how to add RefreshControl in your tableView

    1. Take a refresh control object in your interface as UIrefreshControl *refreshControl;
    2. Alloc init the refresh control & add it to the tableview you are using as a subView as-[myTableView addSubView:refreshControl];
    3. You can also add background color as well as the tint-color of your refresh Control.
    4. The refresh control itself cannot start refresh operation when it is created. Instead, when the table view is pulled down sufficiently, the refresh control triggers the UIControlEventValueChanged event as shown below-

        -(void)addRefreshControl{
    
            refreshControl = [[UIRefreshControl alloc]init];
        [myTableView addSubview:refreshControl];
        [refreshControl addTarget:self action:@selector(refreshTable) forControlEvents:UIControlEventValueChanged];
    
        }

     

    5. Now refresh control will work so try to pull down the table until it triggers the refresh.
    6. The only thing left now is hiding the Refresh Control you can do it by simply using this-

     [myTableView endRefreshing];

    Use it where you find it the need to stop or hide Refresh Control.

    Thanks for reading.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: