4thSpace 4thSpace - 1 year ago 124
iOS Question

How to dismass modal viewcontroller without navigationcontroller?

I have two

. There is no embedded navigationcontroller. They are connected by a segue, which is a "Present Modally".

I have a button on scene2. When it is clicked, I call this code:


I can see the code is hit but nothing happens. What am I doing wrong?

Answer Source

Whay you are doing wrong is that you are pushing a view controller to a non existing navigation controller.

Basically when you say self.navigationController? that returns nil because there is no navigation controller. So the pop function doesn't get called.

In your case you have two options:

What you have to do is call self.dismissViewControllerAnimated(true, completion: nil).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download