原型:ui
- (void)presentViewController:(UIViewController *)viewControllerToPresent animated:(BOOL)flag completion:(void (^)(void))completionspa
描述:
.net
Presents a view controller modally.
In a horizontally compact environment, the presented view is always full screen. In a horizontally regular environment, the presentation depends on the value in the modalPresentationStyle property.
This method sets the presentedViewController property to the specified view controller, resizes that view controller's view based on the presentation style and then adds the view to the view hierarchy. The view is animated onscreen according to the transition style specified in the modalTransitionStyle property of the presented view controller.
The completion handler is called after the viewDidAppear: method is called on the presented view controller.blog
注意上面紅色文字的地方。
ci
通常來講,頁面跳轉必須在viewDidLoad和viewDidAppear以後才能進行,若是是在presentViewController:animated:completion:的completion中跳轉,能夠確保頁面跳轉是在viewDidAppear以後進行的。不然,就會有可能提示Warning: Attempt to present on whose view is not in the window hierarchy!get
參考:原型
對Warning: Attempt to present on whose view is not in the window hierarchy!的解決方案
it