Reputation: 418
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];
Upvotes: 0
Views: 2382
Reputation: 8585
It turns out that UIRefreshControl doesn't require a UITableView at all. refreshControl
is a property of UIScrollView. You can set it on anything that inherits from UIScrollView, which includes UITableView of course, but also other classes such as UICollectionView.
Upvotes: 0
Reputation: 418
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;
}
Upvotes: 8
Reputation: 9944
The documented way is using an UITableViewController
. Anything else can work, but as it's not documented, it may break on next iOS versions.
I'd just use an UITableViewController
in your case.
Upvotes: 0