这可能是因为您的 rootViewController(用于您的主 UIWindow)设置为 Navigationcontroller 而不是您的 TabBar。如果您不希望 Tabbar 消失,只需将其设置为您的根视图控制器
在 AppDelegate 的 appDidFinishLaunching 中执行以下操作
LoginViewController *loginViewController = [[FirstViewController alloc] init];
UINavigationController *loginNavigationController = [[UINavigationController alloc] loginViewController];
[firstViewController release];
self.window.rootViewController = loginNavigationController;
然后在您的登录页面中:
- (void)loginSuccessfull
{
FirstViewController *firstViewController = [[FirstViewController alloc] init];
UINavigationController *firstNavigationController = [[UINavigationController alloc] initWithViewController:firstViewController];
[firstViewController release];
SecondViewController *secondViewController = [[SecondViewController alloc] init];
UINavigationController *secondNavigationController = [[UINavigationController alloc] initWithViewController:secondViewController];
[secondViewController release];
UITabBarController *tabBarController = [[UITabBarController alloc] init];
[tabBarController setViewControllers:
[NSArray arrayWithObjects:firstNavigationController, secondNavigationController, nil]];
[firstNavigationController release];
[secondNavigationController release];
[self.navigationController pushViewController:tabBarController];
[tabBarController release];
}
如果您仍然需要导航功能,只需将您的 viewControllers 包装在 UINavigationController 中,并将周围的 navigationController 添加到 tabBar,而不是 UIViewcontroller