presentModalViewController和presentViewController之间的区别?

YuA*_*uAo 24 iphone viewcontroller ios

在iOS 5 SDK中,有两种方法是UIViewController,presentModalViewController:animated:和presentViewController:animated:completion:.

这两种方法有什么区别?

文档说:presentViewController:animated:completion:方法是从iOS 5.0开始呈现模态视图的首选方式.

如果我在iOS 5中使用presentModalViewController:动画,它会导致错误吗?

它们功能相同吗?

Dan*_*iel 24

他们似乎做了与苹果文档指出的相同的事情,因为iOS 5.0 presentViewController是呈现视图控制器的首选方式,现在似乎presentViewController让你有一个完成处理程序,而在你没有它之前.

并且没有旧的presentModalViewController应该在iOS 5.0上正常,如果它导致了一个错误,这将是所有旧应用程序的问题,并且不会非常向后兼容.此外,它似乎现在presentViewController你可以得到很多详细信息有关的viewController层次,因为我们有presentingViewController,presentedViewController性质.


Dat*_*yen 13

另一个重要的注意事项是,将来不推荐使用presentModalViewController,如UIKit框架的UIViewController.h(Xcode版本4.3.1)中所述:

// Display another view controller as a modal child. Uses a vertical sheet transition if animated.This method has been replaced by presentViewController:animated:completion:
// It will be DEPRECATED, plan accordingly.
- (void)presentModalViewController:(UIViewController *)modalViewController animated:(BOOL)animated; 

// Dismiss the current modal child. Uses a vertical sheet transition if animated. This method has been replaced by dismissViewControllerAnimated:completion:
// It will be DEPRECATED, plan accordingly.
- (void)dismissModalViewControllerAnimated:(BOOL)animated;
Run Code Online (Sandbox Code Playgroud)