码迷,mamicode.com
首页 > 其他好文 > 详细

presentViewController:animated:completion:的特殊之处

时间:2015-02-28 16:52:20      阅读:146      评论:0      收藏:0      [点我收藏+]

标签:

原型:

- (void)presentViewController:(UIViewController *)viewControllerToPresent animated:(BOOL)flag completion:(void (^)(void))completion


描述:

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.

注意上面红色文字的地方。

一般来说,页面跳转必须在viewDidLoad和viewDidAppear之后才能进行,如果是在presentViewController:animated:completion:的completion中跳转,可以确保页面跳转是在viewDidAppear之后进行的。否则,就会有可能提示Warning: Attempt to present on whose view is not in the window hierarchy!


参考:

对Warning: Attempt to present on whose view is not in the window hierarchy!的解决方案


presentViewController:animated:completion:的特殊之处

标签:

原文地址:http://my.oschina.net/ioslighter/blog/380765

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!