我有一个 tableView
并且需要在 tableView
重新加载后执行一个功能。我如何知道 reloadData
是否已完成?假设我有填充 tableView
的 methodA,一旦 [tableView1 reloadData]
完成,我想调用 methodB。谁能帮我这个?我已经搜索了几个小时...谢谢!
- (void) methodA
{
NSString *URLa = [NSString stringWithFormat:@"http://www.website.com/page.php?
v1=%@&v2=%@&v3=%@",v1, v2, v3];
NSURL *url = [NSURL URLa];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
(void) [[NSURLConnection alloc] initWithRequest:request delegate:self];
[tableView1 reloadData];
}
最佳答案
您可以在 UITableView 甚至子类 UITableView 上添加方法/类别:
-(void)reloadDataAndWait:(void(^)(void))waitBlock {
[self reloadData];//if subclassed then super. else use [self.tableView
if(waitBlock){
waitBlock();
}
}
你需要将它用作
[self.tableView reloadDataAndWait:^{
//call the required method here
}];
关于iphone - 仅在 reloadData 完成后调用函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15218861/