2015-03-03 153 views
0

我有一個標籤欄控制器與三個選項卡,我設置編程。兩個第一個只是UIViewController,但第三個是我從另一個故事板獲得的UISplitViewController。一切都很好,但是當我在縱向模式下顯示主視圖時,這個顯示在標籤欄的頂部。我想繼續顯示完整的標籤欄。從分離視圖控制器的主顯示在標籤欄

enter image description here

試圖展示從在主視圖中的項目欄按鈕的UIAlertController(該按鈕不會在圖像中存在)作爲酥料餅被顯示在主視圖後面時,這也產生問題。

有誰知道我該如何解決這個問題?

我把他們的方式編程是這樣(的情況下,它可以幫助):

UIViewController *view1 = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"FirstView"]; 
UIViewController *view2 = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"SecondView"]; 

UIViewController *view3 = [[UIStoryboard storyboardWithName:@"StoryboardSplit" bundle:nil] instantiateViewControllerWithIdentifier:@"MySplitView"]; 

UISplitViewController *splitViewController = (UISplitViewController *)view3; 
UINavigationController *navigationController = [splitViewController.viewControllers lastObject]; 
navigationController.topViewController.navigationItem.leftBarButtonItem = splitViewController.displayModeButtonItem; 
splitViewController.delegate = self; 

NSMutableArray *tabViewControllers = [[NSMutableArray alloc] init]; 
[tabViewControllers addObject:view1]; 
[tabViewControllers addObject:view2]; 
[tabViewControllers addObject:splitViewController]; 

[self setViewControllers:tabViewControllers]; 

view1.tabBarItem = 
[[UITabBarItem alloc] initWithTitle:@"view1" 
           image:[UIImage imageNamed:@"view1"] 
           tag:1]; 
view2.tabBarItem = 
[[UITabBarItem alloc] initWithTitle:@"view2" 
           image:[UIImage imageNamed:@"view2"] 
           tag:2]; 
view3.tabBarItem = 
[[UITabBarItem alloc] initWithTitle:@"view3" 
           image:[UIImage imageNamed:@"view3"] 
           tag:3]; 
+0

我認爲沒關係。您可以左滑動來隱藏它。在橫向方向一切都很好。 – 2015-03-03 14:51:03

+0

根據文檔,'UISplitViewController'必須始終是根視圖控制器。在你的情況下,選項卡視圖控制器是根。 – HAS 2015-03-03 15:40:45

+0

UISplitViewController不必總是iOS 8的根。請參閱[Apple開發者論壇](https://forums.developer.apple.com/thread/15118) – user3847320 2015-10-30 18:56:41

回答

0

嘗試導入QuartzCore,然後設置TabBarController.tabBar.layer.zposition = 1。當然像更換了的TabBar必需品與您的標籤欄的名稱等。

這是斯威夫特的作品,然而通過你自己的倡議,你可以將其工作到Obj-C

+0

謝謝。它會使工作,但如果主視圖是一個長列表,它不會隱藏最後一行的一部分? – fray88 2015-03-03 15:23:07

+0

我不這麼認爲,我沒有在標籤欄中使用過它,但是我已經在導航欄中進行了設置,並且將其設置爲所有內容的最前面,直到另行告知爲止。 – 2015-03-03 15:26:40

+1

您是否足夠清楚您在標籤欄上設置zPosition的位置?例如它是否在UISplitViewControllerDelegate方法中?也許在UITabBarController的viewDidLoad()中?我曾嘗試這個建議是很多地方,但主視圖控制器繼續出現在標籤欄控制器上方。 – user3847320 2015-10-30 18:40:07

相關問題