如果用户未登录,我的应用程序有一个包含 4 个项目的 TabBar。如果用户已登录,则 TabBar 有 5 个项目。 当用户启动应用程序时,didFinishLaunchingWithOptions 方法检查用户是否已登录:
ShoutboxViewController *viewController1 = [[ShoutboxViewController alloc] initWithNibName:@"ShoutboxViewController" bundle:nil];
UINavigationController *view1 = [[UINavigationController alloc] initWithRootViewController:viewController1];
...
self.tabBarController = [[UITabBarController alloc] init];
if (login == TRUE) {
self.tabBarController.viewControllers = [NSArray arrayWithObjects:view1, view4, view3, view5, view2, nil];
} else {
self.tabBarController.viewControllers = [NSArray arrayWithObjects:view1, view4, view3, view2, nil];
}
我的问题是:如何在登录/注销后添加/删除选项卡,例如登录 View Controller
最佳答案
你试过 UITabBarController 方法了吗?:
- (void)setViewControllers:(NSArray *)viewControllers animated:(BOOL)animated
关于ios - 登录后添加TabBar Item,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19737656/