2012-02-20 100 views
0

有人能指出我如何在UITabBarController里面设置UINavigationController的方向吗?我有一种感觉,我使用initWithRootViewController错误。UITabBarController里面的UINavigationController问题

ViewController1 *viewController1 = [[[ViewController1 alloc] initWithNibName:@"ViewController1" bundle:nil] autorelease]; 
self.navController = [[[UINavigationController alloc] initWithRootViewController:viewController1] autorelease]; 
ViewController2 *viewController2 = [[[ViewController2 alloc] initWithNibName:@"ViewController2" bundle:nil] autorelease]; 
ViewController3 *viewController3 = [[[ViewController3 alloc] initWithNibName:@"ViewController3" bundle:nil] autorelease]; 
ViewController4 *viewController4 = [[[ViewController4 alloc] initWithNibName:@"ViewController4" bundle:nil] autorelease]; 

self.tabBarController = [[[UITabBarController alloc] init] autorelease]; 
_tabBarController.viewControllers = [NSArray arrayWithObjects:navController, viewController2, viewController3, viewController4, nil]; 

self.tabBarController.delegate = self; 
self.window.rootViewController = self.tabBarController; 
[self.window makeKeyAndVisible]; 

感谢您的任何提示球员。

回答

1

在AppDelegate中,你把这个:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{ 

    self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease]; 
    // Override point for customization after application launch. 
    UIViewController *viewController1 = [[[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil] autorelease]; 
    UINavigationController *navC1 = [[UINavigationController alloc] initWithRootViewController:viewController1]; 
    UIViewController *viewController2 = [[[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil] autorelease]; 
    UINavigationController *navC2 = [[UINavigationController alloc] initWithRootViewController:viewController2]; 
    UIViewController *viewController3 = [[[FirstViewController alloc] initWithNibName:@"ThirdViewController" bundle:nil] autorelease]; 
    UINavigationController *navC3 = [[UINavigationController alloc] initWithRootViewController:viewController3]; 
    UIViewController *viewController4 = [[[SecondViewController alloc] initWithNibName:@"ForthViewController" bundle:nil] autorelease]; 
    UINavigationController *navC4 = [[UINavigationController alloc] initWithRootViewController:viewController4]; 
    self.tabBarController = [[[UITabBarController alloc] init] autorelease]; 
    self.tabBarController.viewControllers = [NSArray arrayWithObjects:navC1, navC2, navC4, navC4, nil]; 
    self.window.rootViewController = self.tabBarController; 
    [self.window makeKeyAndVisible]; 
    return YES; 

} 

希望有所帮助(对不起,我的英文不好:-));

+0

感谢您的回复阿尔贝托。当我回到这个问题并回报时,我会进行测试。 – crewshin 2012-02-28 19:21:24

相关问题