presentModalViewController和presentViewController之间的区别?

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

这两种方法有什么区别?

文档说:presentViewController:animated:completion:方法是展示iOS 5.0以上模式视图的首选方法。

如果我使用一个presentModalViewController:在iOS 5中animation,会导致一个错误?

它们在function上是否相同?

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

没有老的presentModalViewController应该罚款在iOS 5.0,如果它造成了一个错误,这将是所有的旧应用程序的问题,并不会很向下兼容。 此外,现在看来,使用presentViewController您可以获得更多关于viewController层次结构的信息,因为我们presentingViewController了ViewController, presentedViewController属性。

另一个重要的注意事项是pre​​sentModalViewController将在以后被弃用,如UIKit框架(Xcode版本4.3.1)的UIViewController.h中所提到​​的:

 // 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;