presentViewController:animated:completion:的特殊之处
博客专区 > yoyoso 的博客 > 博客详情
presentViewController:animated:completion:的特殊之处
yoyoso 发表于3年前
presentViewController:animated:completion:的特殊之处
  • 发表于 3年前
  • 阅读 1788
  • 收藏 0
  • 点赞 0
  • 评论 0

腾讯云 技术升级10大核心产品年终让利>>>   

原型:

- (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!的解决方案


共有 人打赏支持
粉丝 47
博文 117
码字总数 42471
×
yoyoso
如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
* 金额(元)
¥1 ¥5 ¥10 ¥20 其他金额
打赏人
留言
* 支付类型
微信扫码支付
打赏金额:
已支付成功
打赏金额: