开发者

Push a view from a TabBarController programmatically created

开发者 https://www.devze.com 2023-03-19 09:03 出处:网络
I have created a tab bar controller as follows: tabBarController = [[UITabBarController alloc] init]; tabBarController.view.frame = CGRectMake(0, 0, 320, 460);

I have created a tab bar controller as follows:

tabBarController = [[UITabBarController alloc] init];
tabBarController.view.frame = CGRectMake(0, 0, 320, 460);

NSMutableArray *tabsArray = [[NSMutableArray alloc] init];

//tab1: dive inf开发者_运维问答o
LogsDetailDive *logsDetailDive = [[LogsDetailDive alloc] initWithNibName:@"LogsDetailDive" bundle:nil];
[logsDetailDive initWithLogSelected:logSelected:siteSelected];
logsDetailDive.title = @"Info";
logsDetailDive.tabBarItem.image = [UIImage imageNamed:@"/images/logs.png"];
[tabsArray addObject:logsDetailDive];

//tab2: deco info
...

//tab3: equipment info
...

//tab3: computer info
...

tabBarController.viewControllers = tabsArray;

[logsDetailDive release];

[self.view addSubview:tabBarController.view];

This tab controller is pushed from a previous table view into the navigation controller. What I'm trying to get now is to show another view pushed from a tableview in LogsDetailDive, but I really cannot understand what I am missing, since it doesn't work. Can you suggest something? Thanks


UITabBarController reference

Because the UITabBarController class inherits from the UIViewController class, tab bar controllers have their own view that is accessible through the view property. When deploying a tab bar interface, you must install this view as the root of your window. Unlike other view controllers, a tab bar interface should never be installed as a child of another view controller.

So the bottom line, this should not be done, and will cause some problems. If you need a tabbar layout you should instead use a toolbar.

0

精彩评论

暂无评论...
验证码 换一张
取 消