UIRefreshControl – Pull To Refresh in iOS 7 [duplicate]

You do not have to explicitly set frame or start UIRefreshControl. If it is a UITableView or UICollectionView, it should work like a charm by itself. You do need to stop it though.

Here is how you code should look like:

- (void)viewDidLoad {
    [super viewDidLoad];
    refreshControl = [[UIRefreshControl alloc]init];
    [refreshControl addTarget:self action:@selector(refreshTable) forControlEvents:UIControlEventValueChanged];

    if (@available(iOS 10.0, *)) {
        self.mytableView.refreshControl = refreshControl;
    } else {
        [self.mytableView addSubview:refreshControl];
    }
}

In your refreshTable function, you need to stop it when you are done refreshing your data. Here is how it is going to look like:

- (void)refreshTable {
    //TODO: refresh your data
    [refreshControl endRefreshing];
    [self.mytableView reloadData];
}

Please note that if you are refreshing your data asynchronously then you need to move endRefreshing and reloadData calls to your completion handler.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)