1

我无法将某个选项卡视图设置为 UiNavigation 控制器。我得到的警告是:

Pushing a navigation controller is not supported

这是我的代码:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    UIViewController *viewController1, *viewController2, *viewController3, *viewController4;
        viewController1 = [[HomeViewController alloc] initWithNibName:@"HomeViewController_iPhone" bundle:nil];
        viewController2 = [[SearchViewController alloc] initWithNibName:@"SearchViewController_iPhone" bundle:nil];
        viewController3 = [[ListViewController alloc] initWithNibName:@"ListViewController_iPhone" bundle:nil];
        viewController4 = [[InfoViewController alloc] initWithNibName:@"InfoViewController_iPhone" bundle:nil];

    self.tabBarController = [[UITabBarController alloc] init];
    UINavigationController * listNavController = [[UINavigationController alloc] initWithRootViewController:viewController3];
    self.tabBarController.viewControllers = [NSArray arrayWithObjects:viewController1, viewController2, listNavController, viewController4, nil];
    self.window.rootViewController = self.tabBarController;
    [self.window makeKeyAndVisible];
    return YES;
}
4

1 回答 1

0
self.tabBarController.viewControllers = [NSArray arrayWithObjects:viewController1, viewController2, listNavController, viewController4, nil];

self.tabBarController.viewControllers = [NSArray arrayWithObjects:viewController1, viewController2, viewController3, viewController4, nil];

并在需要时保留对导航控制器的引用。我认为这将是正确的方法,但您也可以将导航控制器包装在一个简单的 UIViewController 中。如果不能保证 viewController3 始终是堆栈中最底层的 VC,您可能会希望这样做。

于 2012-07-05T04:07:49.973 回答