简体   繁体   中英

Present XIB viewController with navigation bar (Swift)

This is the code I'm using

var xibvc = TestXibViewController()
var navb = UINavigationController(rootViewController: xibvc)
self.presentViewController(xibvc,animated: true, completion: nil)

I'm tying to present xibviewcontroller with a navigation bar, It gives me this error

reason: 'Application tried to present modally an active controller

although, it works fine if i try pushViewController

Your code makes no sense. What is navb for? You create it and then you never use it.

You probably meant to say:

self.presentViewController(navb,animated: true, completion: nil)
                           ^^^^

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM