Search code examples
iphoneiosuiviewcontrolleruirefreshcontrol

How to end UIRefreshControl without UITableViewController


I have created a UIRefreshcontrol without a TableViewController. My question is how I would end it inside another method? This is how I created it;

UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init];
    [refreshControl addTarget:self action:@selector(handleRefresh) forControlEvents:UIControlEventValueChanged];
    [_tableView addSubview:refreshControl];

Solution

  • I discovered with help from @Justin Paulsson that this could be done;

    UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init];
        [refreshControl addTarget:self action:@selector(handleRefresh:) forControlEvents:UIControlEventValueChanged];
        [_tableView addSubview:refreshControl];
    

    -

    -(void) handleRefresh:(UIRefreshControl *)controller
        {
            //Refresh code
            controller.endRefreshing;
        }