2017-07-27 145 views
0

我怎麼能說TabbarViewControllers連接的viewController從簡單的UIViewController這裏簡單的UIViewController嵌入的UINavigationController。我需要UINavigationController在將其中一個移動到其他viewController時提供的Push和Pop效果。在谷歌挖掘後,我發現推動標籤欄視圖控制器內導航堆棧不是一個很好的方式來構建應用程序。我嘗試創建自定義事務動畫,但它與UINavigation事務效果不同。請給出一些建議或解決方案。謝謝!!如何從嵌入導航控制器的簡單視圖控制器調用標籤欄視圖控制器?

+0

意味着你需要從普通視圖控制器打開的UITabBarController,對不對? – Nirmalsinh

+0

是@Nirmalsinh。 –

回答

1

您可以直接將UITabbarController設置爲窗口的rootViewController。

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil]; 
_tabObj = (TabbarViewController*) [storyboard instantiateViewControllerWithIdentifier:@"TabbarViewController"]; 
self.window.rootViewController = _tabObj; 

查看上述代碼。

+0

另一個選項簡單'現在modally'也可以工作 –

+0

目前modally不給動畫像UINavigationController推動畫 –

0

作爲Nirmalsinh的答案,你可以設置視圖控制器符合UITabBarControllerDelegate作爲你的self.window.rootViewController,那麼它應該有UITabBarController裏面。

var tabBarController: UITabBarController 

,那麼你可以在每個標籤的導航和視圖控制器的

let firstViewController = FirstViewController() 
let firstNavigationController = UINavigationController(rootViewController: firstViewController) 
// other setter 

tabBarController.viewControllers = [ 
    firstNavigationController 
] 

然後裏面FirstViewController,您可以撥打

let secondViewController = SecondViewController() 
navigationController?.pushViewController(SecondViewController, animated: true) 
相關問題