use*_*887 5 xcode ios uirefreshcontrol

UIRefreshControl切换标签后我被卡住了,它只发生在第一个标签上.在TabBar里面我有两个带UIViewControler的标签,里面有UITableView.
我尝试过在这里建议的所有解决方案,但没有一个能为我工作.
以下是我正在做的事情.
- (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];
}
Run Code Online (Sandbox Code Playgroud)
由于这个问题已被查看数百次。在这里添加我的解决方案可能会对其他人有所帮助。
就我而言,这是由于refreshControl. 您需要refreshControl将两个视图分开。我最终创建refreshControlFirstView并refreshControlSecondView解决了问题。
| 归档时间: |
|
| 查看次数: |
501 次 |
| 最近记录: |