Push UINavigationController programmatically. iOS9

£可爱£侵袭症+ 提交于 2019-12-23 02:42:41

问题


I want to display a navigation controller programmatically. This code works perfect on iOS 8, but on iOS 9 it doesn't work.

var vc = storyboard?.instantiateViewControllerWithIdentifier("view_controller_id") as! UIViewController;
var nc = UINavigationController()
        nc.setViewControllers([vc], animated: false)
        navigationController?.pushViewController(nc, animated: true)

After that I am getting this error

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Pushing a navigation controller is not supported'


回答1:


You can't push a navigation controller to another navigation controller. You will have to show your navigation view controller with viewcontrollers modally or just push your view controllers to the active navigation controller.



来源:https://stackoverflow.com/questions/33044758/push-uinavigationcontroller-programmatically-ios9

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!