Ankit
Ankit

Reputation: 280

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

Upvotes: 0

Views: 1623

Answers (1)

matt
matt

Reputation: 535944

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)
                           ^^^^

Upvotes: 1

Related Questions