Reputation: 4569
Suppose I have a navigation controller with root view controller A, and I need to present a view controller B, I can do with either of the following two ways:
self.navigationController!.presentViewController(b, animated: true)
or
self.presentViewController(b, animated: true)
But, I just wonder, what is the difference between these two ways?
Upvotes: 1
Views: 882
Reputation: 57040
They are analogous - both initiate a modal presentation.
In recent iOS versions, modal presentation always travels to the top most container view controller. So when your view controller (aka self
) is container inside a navigation controller (aka self.navigationController
), when you attempt presenting on the view controller, it will pass the presentation duties to the navigation controller. You can verify this by logging the presentingController
of b
once the presentation is completed. In both cases, presentingController
will be the navigation controller.
Upvotes: 2