2011-05-21 48 views
1

我想在另一個TabBarController上呈現一個TabBarController。我的應用程序的MainWindow.xib文件看起來是這樣的:UITabBar模態ViewContoller

Files Owner 
First Responder 
My App App Delegate 
Window 
TabBarContoller 
    +TabBar 
    +Nav Controller Subclass (a custom class) 
     +Navigation Bar 
     +Table View Contoller Subclass (custom class) 
     +Tab Bar Item 
    +Second View Controller (not yet hooked up) 

我想,當點擊TableView中的項目,顯示廈門國際銀行文件。這個xib文件有一個TabBarController作爲主視圖,但是當顯示視圖時,標籤欄和導航欄都不可見。我使用以顯示它的代碼是:

MyAppAppDelegate *delegate = [[UIApplication sharedApplication] delegate]; 
[delegate.customNavController presentModalViewController:customDetailEditViewController animated:YES]; 

如果我使用下面的代碼視圖控制器推入棧中,我看到正確的導航欄,但被示出從根視圖控制器的TabBar而不是從被推送的視角來看。

[delegate.customNavController pushViewController:customDetailEditViewController animated:YES]; 

我甚至試圖消除TabBarController並手動執行自己的TabBar代表但是出現同樣的效果(或者沒有導航欄或的TabBar,或從根的ViewController所述導航欄/的TabBar)。

編輯:我已將源碼上傳到http://mi6.nu/tabcontroller.zip。如果有人對iOS有更多的經驗可以看看,我會非常感激。

EDIT2:到目前爲止,我來最接近的是呈現先的TabBar內模態的視圖控制器,所以我的看法是這樣的:

NavigationBar 
[   ] 
[   ] 
[---View---] 
[   ] 
[   ] 
TabBar from the pushed view 
TabBar from the root view 

要做到這一點,我使用:

UITabBarController *tabBarController = [[UITabBarController alloc] init]; 

    UIViewController *directionsView = [[UIViewController alloc] init]; 
    txtDirections = [[UITextView alloc]initWithFrame:CGRectMake(0,0,self.view.frame.size.width, self.view.frame.size.height)]; 
    [directionsView.view addSubview:txtDirections]; 

    IconPickerViewController *iconPicker = [[IconPickerViewController alloc]init]; 
    tabBarController.viewControllers = [NSArray arrayWithObjects:recipeDetailEditViewController,directionsView,iconPicker, nil]; 
    [directionsView release]; 
    [iconPicker release]; 

    MyAppAppDelegate *delegate = [[UIApplication sharedApplication] delegate]; 
    [delegate.rootNavController presentModalViewController:recipeDetailEditViewController animated:YES]; 

這只是複雜的一切,雖然,因爲)這不是理想的,因爲我有兩個tabbars和b)所有控件(所有的編輯控件)必須在TableViewController因此它們的值可以加載/保存編輯項目。如果推送的視圖可以處理加載/保存並出現在根標籤的頂部,將會容易得多。

當然,這一定是可能的?

回答

2

這是一個絕對的噩夢,但我最終得到了它從TableViewController模態呈現視圖中工作單擊Add按鈕時:

[delegate.rootController presentModalViewController:recipeDetailEditViewController animated:YES]; 

delegate.rootController是根TabBarController 的XIB文件我'呈現沒有TabBarController,而是一個UIView,一個導航欄和一個TabBar。這在從NavigationController中以模態方式呈現時似乎工作。 Window Layout

0

你爲什麼要把所有的東西放在main.xib中? 嘗試將第二個標籤欄移出主窗口xib,並將其放入customDetailEditViewController中。

+0

它不在主xib中。有主要的xib,然後是第一個導航constoller這是另一個xib,然後我的CustomEditViewController,這是另一個xib。 – Echilon 2011-05-22 06:03:39

+0

Google正在mi6.nu地址處檢測到惡意軟件。 – Rayfleck 2011-05-22 14:53:17

+0

是的,它正在等待審查,但文件是安全的。 – Echilon 2011-05-22 15:30:42