0

所以我用一個的UITabBarController應用的模板來創建一個應用程序來創建UINavigationView或UITableView的,我覺得我的情況我也解決不了自己。我正在尋找創建我的最後一個視圖(ViewViewController4實例與FourthViewController類)實際上是一個UITableViewController/UITableView /或UINavigationController。我無法確切知道哪些是最適合我需要的。尋找在現有的UITabBarController

基本上它應該的信息屏幕,具有tableview中,你可以點擊一個單元格,選擇了不同的看法(設置,關於應用程序,幫助,電子郵件支持)。任何想法如何實現這一點?我試圖替換列出的UIViewController(viewcontroller4)的UINavigation控制器。下面

是我appdelegate.m代碼以供參考:

- (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; 
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { 
    viewController1 = [[FirstViewController alloc] initWithNibName:@"FirstViewController_iPhone" bundle:nil]; 
    viewController2 = [[SecondViewController alloc] initWithNibName:@"SecondViewController_iPhone" bundle:nil]; 
    viewController3 = [[ThirdViewController alloc] initWithNibName:@"ThirdViewController_iPhone" bundle:nil]; 
    viewController4 = [[FourthViewController alloc] initWithNibName:@"FourthViewController_iPhone" bundle:nil]; 
} else { 
    viewController1 = [[FirstViewController alloc] initWithNibName:@"FirstViewController_iPad" bundle:nil]; 
    viewController2 = [[SecondViewController alloc] initWithNibName:@"SecondViewController_iPad" bundle:nil]; 
    viewController3 = [[ThirdViewController alloc] initWithNibName:@"ThirdViewController_iPad" bundle:nil]; 
    viewController4 = [[FourthViewController alloc] initWithNibName:@"FourthViewController_iPad" bundle:nil]; 
} 
self.tabBarController = [[UITabBarController alloc] init]; 
self.tabBarController.viewControllers = [NSArray arrayWithObjects:viewController1, viewController2, viewController3, viewController4, nil]; 
self.window.rootViewController = self.tabBarController; 
[self.window makeKeyAndVisible]; 
return YES;} 

回答

1

不知道你如何試圖創建UINavigationController但它會正常工作。您創建viewControllers後,請執行下列操作:

UINavigationController *navController = [[UINaviagtionController alloc] initWithRootViewController:viewController4]; 
self.tabBarController = [[UITabBarController alloc] init]; 
self.tabBarController.viewControllers = [NSArray arrayWithObjects:viewController1, viewController2, viewController3, navController, nil]; 
// rest of your code 
+0

謝謝!現在我怎麼把這個鏈接連接到FourthViewController的xib中?當我運行它時顯示的是在文件所有者(我認爲)和導航視圖中關聯的UIView。我需要爲UINavigationViewController聲明一個IBOutlet嗎? – Macness 2011-12-20 03:40:04

+0

你根本不需要改變你的XIB。本示例以編程方式創建導航控制器。您的fourthViewController將保持每個XIB正確配置。您需要編寫代碼以從那裏推送所需的視圖控制器。 – XJones 2011-12-20 03:52:11

+0

所以現在我可以在該UIView中使用TableView進行導航?另外,感謝您花時間回答我的問題。 – Macness 2011-12-20 03:59:02