2011-10-23 94 views
1

我有一個iPhone應用程序,它是一個基於導航的應用程序。如何將基於導航的iPhone應用程序轉換爲基於TabBar的應用程序

客戶需要將60%的應用程序轉換爲全局TabBar。 (即在應用視圖中包含60%的一個tabbar)

那麼,在這裏遵循的最佳實踐是什麼? 它是否包含使用IB的TabBar到Window? 或添加更改導航代碼跨越整個應用程序,並推送一個TabBarController而不是常規的ViewController?

請給我提供一些想法。

謝謝。

回答

0

我用了一個新的基於窗口的應用程序,並把下面的代碼:

的想法是創建一個的UITabBarController並把它NavigationController代替ViewControllers的。

並且每個navigationController將導航到它自己的一組ViewContrllers。

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 
    UITabBarController* tabBarContoller = [[UITabBarController alloc]init]; 

    Cross1VC* cross1VC = [[Cross1VC alloc]initWithNibName:@"Cross1VC" bundle:nil]; 
    cross1VC.title = @"Cross 1"; 
    UINavigationController* crossNav = [[UINavigationController alloc]initWithRootViewController:cross1VC]; 
    crossNav.title = @"Cross"; 
    [cross1VC release]; 

    Part1VC* part1VC = [[Part1VC alloc]initWithNibName:@"Part1VC" bundle:nil]; 
    part1VC.title = @"Part 1"; 
    UINavigationController* partNav = [[UINavigationController alloc]initWithRootViewController:part1VC]; 
    partNav.title = @"Part"; 
    [part1VC release]; 


    NSArray* viewControllers = [NSArray arrayWithObjects:crossNav, partNav, nil]; 
    [tabBarContoller setViewControllers:viewControllers animated:YES]; 

    //tabBarContoller.delegate = [[SomeDelegateHandlerClass alloc]init]; // assign, not retain 

    [self.window addSubview:tabBarContoller.view]; 
    //[tabBarContoller release]; // make instance variable and release in dealloc 
    [self.window makeKeyAndVisible]; 
    return YES; 
} 
相關問題