您的位置:首页 > 其它

创建TabBarController中包含NavigationController

2016-03-10 10:37 288 查看
当用TabBarController作为app的根控制器时,还需要在里面的子viewController中加入NavigationController,这种情况在appDelegate可以这样写

MainTabBarViewController *mainTabbar = [[MainTabBarViewController alloc] init];
MessagesViewController *messagesVC = [[MessagesViewController alloc] init];
UINavigationController *messagesNav = [[UINavigationController alloc] initWithRootViewController:messagesVC];
BookingsViewController *bookingsVC = [[BookingsViewController alloc] init];
UINavigationController *bookingsNav = [[UINavigationController alloc] initWithRootViewController:bookingsVC];
mainTabbar.viewControllers = @[messagesNav,bookingsNav];
self.window.rootViewController = mainTabbar;


如果有登录界面,进入后显示TabBarController,可以在登录界面写

MainTabBarViewController *mainTabbar = [[MainTabBarViewController alloc] init];
MessagesViewController *messagesVC = [[MessagesViewController alloc] init];
UINavigationController *messagesNav = [[UINavigationController alloc] initWithRootViewController:messagesVC];
BookingsViewController *bookingsVC = [[BookingsViewController alloc] init];
UINavigationController *bookingsNav = [[UINavigationController alloc] initWithRootViewController:bookingsVC];
mainTabbar.viewControllers = @[messagesNav,bookingsNav];
[self presentViewController:mainTabbar animated:YES completion:nil];


跳转用present,不能用push
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: