我的 UIRefreshControl
在切换选项卡后卡住了,它只发生在第一个选项卡上。在 TabBar 内部,我有 2 个带有 UIViewControler 的选项卡,其中我有 UITableView。
我已经尝试了所有建议的解决方案 HERE没有一个对我有用。
下面是我正在做的。
- (void)viewDidLoad {
[super viewDidLoad];
data = [[NSMutableArray alloc] initWithArray:[[DataCache sharedCache] getData]];
[self addNavBar];
[self addDataTable];
//for refreshing the table data
UITableViewController *tableViewController = [[UITableViewController alloc] init];
tableViewController.tableView = dataTable;
refreshControl = [[UIRefreshControl alloc] init];
refreshControl.backgroundColor = [UIColor purpleColor];
refreshControl.tintColor = [UIColor whiteColor];
[refreshControl addTarget:self
action:@selector(refresh)
forControlEvents:UIControlEventValueChanged];
[dataTable addSubview:refreshControl];
tableViewController.refreshControl = refreshControl;
}
- (void)refresh {
[self loadSentData];
data = [[NSMutableArray alloc] initWithArray:[[DataCache sharedCache] getSentData]];
[self performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:NO];
}
- (void)reloadData{
[dataTable reloadData];
[refreshControl endRefreshing];
}
最佳答案
因为这个问题已经被浏览了数百次。在此处添加我的解决方案可能会对其他人有所帮助。
在我的例子中,这是由于 refreshControl
。两个 View 都需要单独的 refreshControl
。我最终创建了 refreshControlFirstView
和 refreshControlSecondView
并解决了问题。
关于ios - 使用 UIViewControler 和 UITableView 在 UITabBarController 中切换选项卡后 UIRefreshControl 卡住了,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29056884/