Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

dismissViewControllerAnimated VS popViewControllerAnimated

I want to know what is the different of them. when I can call

[self dismissViewControllerAnimated:YES completion:nil]; 

and when I should call

[self.navigationController popViewControllerAnimated:YES]; 

according document of apple: dismissViewControllerAnimated means "Dismisses the view controller that was presented by the receiver." But I always fail to dismiss view controller by this method.

like image 729
kevin young Avatar asked Jun 18 '12 09:06

kevin young


1 Answers

-dismissViewControllerAnimated:completion:

Used to dismiss an UIViewController, which was presented by the method:

-presentViewController:animated:completion:.

-popViewControllerAnimated:

Method of UINavigationController is used to pop a controller shown by

-pushViewController:animated method of UINavigationController.

In the first case the view controller's view shows as a modal controller (usually from bottom to top), and the second case you are pushing a view controller in the navigation stack of UINavigationController.

like image 192
graver Avatar answered Sep 28 '22 11:09

graver