加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ios – 使用UIViewControler和UITableView在UITabBarController

发布时间:2020-12-14 19:04:22 所属栏目:百科 来源:网络整理
导读:我的UIRefreshControl在切换标签后卡住了,它只在第一个标签上发生.在TabBar里面我有两个带UIViewControler的标签,里面有UITableView. 我已经尝试了所有建议的解决方案HERE,但没有一个适合我. 以下是我正在做的事情. - (void)viewDidLoad {[super viewDidLoad
我的UIRefreshControl在切换标签后卡住了,它只在第一个标签上发生.在TabBar里面我有两个带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.你需要为两个视图单独的refreshControl.我最终创建了refreshControlFirstView和refreshControlSecondView,并解决了这些问题.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读