2011-12-03 2 views
24

iOS 5 SDKには、UIViewController、presentModalViewControllerの2つのメソッドがあります:animated:とpresentViewController:animated:completion:。presentModalViewControllerとpresentViewControllerの違いは?

これら2つの方法の違いは何ですか?

ドキュメンテーションによると、iOS 5.0以降のモーダルビューを表示するには、presentViewController:animated:completion:メソッドが推奨されます。

iOS 5でpresentModalViewController:animatedを使用すると、バグが発生しますか?

機能的に同じですか?

答えて

24

は、彼らはpresentViewControllerが今あなたがいることを持っていなかった前のに対し、あなたは、完了ハンドラを持っていることができますようだ、リンゴdocumentationが指摘するようにpresentViewControllerは、View Controllerを提示する好ましい方法であるのiOS 5.0のように、同じことを行うように見えます。

古いバージョンのすべてのアプリケーションで問題となるバグが発生し、あまり後方互換性がない場合は、古いバージョンのpresentModalViewControllerはiOS 5.0で問題ありません。さらに、presentViewControllerを使用すると、presentingViewController,presentedViewControllerというプロパティがあるので、viewController階層に関する多くの情報を得ることができます。

+0

ありがとう! iOS 5をターゲットにしている場合は、常にpresentViewControllerを使用する必要があります。 – YuAo

+0

iOS 5のみのアプリをお持ちの場合 – Daniel

13

もう一つの重要な注意点は、UIKitフレームワーク(Xcodeのバージョン4.3.1)のUIViewController.hで述べたようにpresentModalViewControllerが、将来的には廃止される予定ということです。

// 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; 
関連する問題