Reputation: 285
What is the difference between:
[self.navigationController presentModalViewController:nav animated:YES];
and
[self presentModalViewController:nav animated:YES];
Where self is a subclass of UIViewController.
Along with that, does it matter how I dismiss the modal view? Example:
[self dismissModalViewControllerAnimated:YES];
or
[self.navigationController dismissModalViewControllerAnimated:YES];
If a modalView is presented by self.navigationController
, will it be dismissed if called on self
, and vice versa?
I know that apple recommends using a protocol and delegate in actual implementation, but I am just trying to find out if the behavior "under the hood" is the same or not.
I have been looking around to try and find an answer to this but I haven't found anything yet, so if this is a duplicate I apologize before hand.
Thanks
Upvotes: 0
Views: 381
Reputation: 2381
what kind of class are you calling this from (ie what is self
). if you are you calling it from a view controller then the difference is that your view controller is presenting the modalviewcontroller
instead of the view controller's navigationcontroller
presenting the modal view
if you use self.navigationcontroller
you can interact with self.navigationitem
which a view controller doesn't have.
EDIT:
Yes, it gives you the ability to push additional ViewControllers
onto the self.navigationController.ViewControllers
array and then use the navigationBar
to move from ViewController to ViewController.
As an example you could do [self.navigationController presentModalViewController:nav animated:YES];
and then if a user clicks a button you could push a ViewController [self.navigationController pushViewController:vc animated:YES];
Then a new View Controller/View would be presented inside of the ModalView. When you dismissed the ModalViewController you would still be transported back to your original view controller.
To answer your second question: You should dismiss the modal view the same way you presented it. So if you use self.navigationController to present, use self.navigationController to dismiss.
Upvotes: 1