ios - 使用 UIViewControler 和 UITableView 在 UITabBarController 中切换选项卡后 UIRefreshControl 卡住了

标签 ios xcode uirefreshcontrol

enter image description here我的 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。我最终创建了 refreshControlFirstViewrefreshControlSecondView 并解决了问题。

关于ios - 使用 UIViewControler 和 UITableView 在 UITabBarController 中切换选项卡后 UIRefreshControl 卡住了,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29056884/

相关文章:

iphone - Objective-C : Proper way to init an NSArray that is a @property

ios - 滚动到 WatchKit 中 WKInterfaceTable 的顶部?

ios - 如何避免在带有 Swift 4 的 iOS 11 中将@objc 与刷新控件一起使用?

ios - 无法使用协变类型 'refreshControl' 覆盖类型 'UIRefreshControl?' 的可变属性 'UIRefreshControl'

ios - 准备 segue NSString 变成 NSObject?

ios - Unity IOS 集成

swift - Xcode/Swift 中的颜色和主题

ios - 快速下拉列表

ios - 在 UIViewController 内部的 UITableView 上拉动刷新

objective-c - 未调用 UIWebViewDelegate 函数