我正在开发基于UITabbar和视图层次结构的应用程序,如下所示。
UITabBarController ----> UINavigationController ----> UIViewController
我有推送通知有效负载,它将打开特定的UIViewController,我可以使用视图控制器Storyboard ID直接显式打开UIViewController,但不会显示tabBar和Navbar。如何转到特定的View Controller,并从AppDelegate didReceiveRemoteNotifications显示TabBar和NavController。
谢谢!
您必须实例化所有VC,并将所有VC设置为他的前任的根:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
let mainStoryboard : UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let yourVC = mainStoryboard.instantiateViewControllerWithIdentifier("YourVC_Identifier");
let yourNavController = mainStoryboard.instantiateViewControllerWithIdentifier("YourNAV_Identifier") as! UINavigationController
let yourTabController = mainStoryboard.instantiateViewControllerWithIdentifier("YourTAB_Identifier") as! UITabBarController
yourNavController.setViewControllers([yourVC], animated: false)
yourTabController.setViewControllers([yourNavController], animated: false)
self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
self.window?.rootViewController = yourTabController
self.window?.makeKeyAndVisible()
return true
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句