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

在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方法。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
回答: 当出现"OpenJDK 64-Bit Server VM warning: Attempt to allocate stack guard pages failed"的警告时,这意味着Java虚拟机(JVM)尝试分配堆栈保护页失败。这通常是由于操作系统对线程数量的限制导致的。在Linux服务器上,Java虚拟机的线程直接映射到操作系统的本机线程,因此操作系统对线程数量的限制也会限制Java可以创建的线程数量。操作系统对系统能够创建的总线程数和每个用户能够创建的线程数都有限制。您可以通过查看/proc/sys/kernel/pid_max和/proc/sys/kernel/threads-max的值来了解操作系统的总限制。此外,/proc/sys/vm/max_map_count的值也会影响线程的创建。如果这些限制太小,在创建过多线程后可能会导致无法分配堆栈保护页的错误。\[3\] #### 引用[.reference_title] - *1* *2* [JMeter-Linux内存不足](https://blog.csdn.net/weixin_31232695/article/details/116626746)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] - *3* [对Java Stack的一次探索](https://blog.csdn.net/weixin_33694172/article/details/91686014)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值