TabBarController的问题

linux_fay linux_fay 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
{
//这里的myTable是一个TableView对象

TablesForCollectionViewController * myTable = [[[TablesForCollectionViewController alloc] initWithNibName:@"TablesForCollectionView" bundle:nil] autorelease];
myTable = [[[TablesForCollectionViewController alloc] initWithStyle:UITableViewStylePlain]autorelease];
myTable.view.frame = CGRectMake(0, 44, 320, 480);

//初始化scrollView对象
UIScrollView *scrollView = [[[UIScrollView alloc] initWithFrame:CGRectMake(0, 44, 320, 440)]autorelease];
scrollView.directionalLockEnabled = YES;
scrollView.pagingEnabled = NO;
scrollView.showsHorizontalScrollIndicator = NO;
scrollView.showsVerticalScrollIndicator = NO;
scrollView.delegate = self;

//初始化collectionView对象
CollectionViewController *collectionView = [[CollectionViewController alloc] initWithNibName:@"CollectionView" bundle:nil];
//collection.view中包含了ScrollView,ScrollView中包含的是myTable的view
if([_tabBarController selectedIndex] == 2){
NSLog(@"CollectionView");
[myTable.tableView reloadData]; //重新加载TableView中的数据
[collectionView.view addSubview:scrollView];
[scrollView addSubview:myTable.view];
}
}


小弟新手,不知道为啥reloadData不起作用,因为我在此按Item时,并没有更新数据。只有重启程序之后才能看到更新了数据。请大侠们指点一二。谢谢!
...全文
评论 14
收藏 已收藏
分享
返回顶部
linux_fay
iOS 29,038 成员 12,459 内容