您的位置:首页 > 产品设计 > UI/UE

Warning: Attempt to present UINavigationController on NavigationController which is already presenti

2017-03-20 00:00 399 查看
摘要: Warning: Attempt to present <UINavigationController: 0x13c57ecd0> on <XXViewController: 0x13c580d10> which is already presenting (null)

在iOS8中,弹出ActionSheet后选择其中一项,然后在ActionSheet的代理方法
actionSheet(actionSheet:clickedButtonAtIndex:)
中使用了
performSegueWithIdentifier
方法来跳转到下一个ViewController时,发现ViewController不但没有跳转,控制台却出现了以下警告:

Warning: Attempt to present <UINavigationController: 0x13c57ecd0> on <XXViewController: 0x13c580d10> which is already presenting (null)

然而在iOS7中一切都正常,也不会出现任何警告。出现这种问题的原因是:

Actionsheets and AlertViews were refactored to AlertControllers (iOS8 only), which are both being presented. So, basically, you’re trying to present a controller where you already have a controller presented (ActionSheet), but by the time the debugger gets it, it’s deallocated and it becomes null, producing the warning you see.

以下是解决办法

1.跳转ViewController这种类型的代码最好写到
actionSheet(actionSheet:, didDismissWithButtonIndex)
方法中,保证ActionSheet消失后才跳转。

2.如果确实需要在
actionSheet(actionSheet: clickedButtonAtIndex: )
就跳转,那么可以做个延时,比如0.1秒之后再调用
performSegueWithIdentifier
方法。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐