29,028
社区成员
发帖
与我相关
我的任务
分享
- (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];
}
}