swift一次 Attempt to present on whose view is not in the window hierarchy的解决方法
做的是二维码扫描,扫描后识别为URL的话就跳转到webview 加载网页,用的是代理传值的方式。扫描到了 值传递到主页 扫描窗体退出,检测值是否是http://开头 是网页就跳转。
问题出在传值到主界面后判断网页链接再跳转的时候 出现Attempt to present on whose view is not in the window hierarchy的错误,也就是传值回去的时候主视图还没打开又要打开浏览视图 然后就乱掉了 不知道要打开啥了。
尝试诸多方法之后找到以下方法:
在扫描结果之后 先跳转到主页,这个时候还没回传结果。
因为是跳过来的 所以用dismiss退回去
self.dismissViewControllerAnimated(true, completion:nil)
然后,重写生命周期中的方法:viewDidDisappear 也就是在视图已经消失、被覆盖或是隐藏时再把值传递过去
override func viewDidDisappear(animated: Bool) {
self.scanDelegate.didReturnScanResult(scanResultValue!);
}
这样就可以了。
swift一次 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!
当我想从一个VC跳转到另一个VC的时候,一般会用 - (void)presentViewController:(UIViewController *)viewControllerToPresent a ...
- 错误:Warning: Attempt to present <UIAlertController: 0x7fd192806e20> on <ViewController: 0x7fd1928048d0> whose view is not in the window hierarchy!
系统:mac OS 10.12 (16A323) Xcod:8.3.3 错误:Warning: Attempt to present <UIAlertController: 0x7fd1928 ...
- Attempt to present <TestViewController2: 0x7fd7f8d10f30> on <ViewController: 0x7fd7f8c054c0> whose view is not in the window hierarchy!
当 storyboard里面的 按钮 即连接了 类文件里面的点击方法 又 连接了 storyboard里 另一个 控制器的 modal 就会出现类似Attempt to present & ...
- Warning: Attempt to present A on B whose view is not in the window hierarchy!
昨天写豆瓣发广播Demo的时候,为了写Demo的简单,就使用了Storyboard,结果执行视图跳转时遇到了这个问题: Warning: Attempt to present <UINaviga ...
- Swift - whose view is not in the window hierarchy 问题解决方法
问题现象:想在页面初始化的时候,使用self.presentViewController方法弹出个告警提示框UIAlertController.但行后报了个如下告警,同时告警框也出不来. 1 2015 ...
- Warning: Attempt to present on whose view is not in模态跳转问题
错误分析: controller A present controller B ,前提是A的view要存在,如果不存在,就会报这个错. 解决方法: 将 ...
- 解决No 'Access-Control-Allow-Origin' header is present on the requested resource.跨域问题(后台(java)解决方法)
附:前端常见跨域解决方案(全) 跨域错误 解决方法 在后台写一个过滤器来改写请求头 附上一个前端不知所以然的后台java代码: public class CorsFilter implements F ...
- Attempt to present <vc> on <vc> which is already presenting <vc>/(null)
在给 tableViewCell 添加长按手势弹出一个 popViewController 的时候,遇到的这个变态问题: Warning: Attempt to present <UINavig ...
- Warning: Attempt to present * on * which is already presenting *
Warning: Attempt to present (要被presented的控制器) on (哪个控制器来presenting) which is already presenting (已经 ...
随机推荐
- Forms and Reports Developer 10g Certified on Windows 10 for EBS 12.x
Forms Developer 10g and Reports Developer 10g are now certified on Windows 10 desktops for E-Busines ...
- DGA GAN——GAN在安全中的应用
DGA的模型:https://github.com/Yuren-Zhong/DeepDGA CNN.LSTM.双向LSTM 论文可以看https://openreview.net/pdf?id=BJL ...
- softmax回归(理论部分解释)
前面我们已经说了logistic回归,训练样本是,(且这里的是d维,下面模型公式的x是d+1维,其中多出来的一维是截距横为1,这里的y=±1也可以写成其他的值,这个无所谓不影响模型,只要是两类问题就可 ...
- python:webbrowser
import webbrowser webbrowser.open_new_tab('www.baidu.com')
- Foundations of Qt Development 学习笔记 Part1 Tips1-50
1. 信号函数调用的时候仅仅会发送出信号,所以不需要执行 ,所以对于信号声明就行,但是不需要进行定义. 2. 只有槽函数可以声明为public,private,或者是protected的,而信号不行. ...
- 演示使用Metasploit入侵Android
文本演示怎么使用Kali Linux入侵Android手机. Kali Linux IP地址:192.168.0.112:接收连接的端口:443. 同一局域网内android手机一部(android ...
- 怎么用HD Tune检测硬盘坏道
HD Tune软件不仅小巧而且很易使用,是一款检测电脑硬盘的优良工具.不仅是电脑硬盘,包括移动硬盘在内一样可以检测.那么,如何使用HD Tune呢?如何使用HD Tune检测磁盘坏道呢? 工具/原料 ...
- Python sh库学习
官方文档有句话"allows you to call any program",并且: helps you write shell scripts in Python by giv ...
- Laravel 5使用Laravel Excel实现Excel/CSV文件导入导出的功能详解
1.简介 本文主要给大家介绍了关于Laravel 5用Laravel Excel实现Excel/CSV文件导入导出的相关内容,下面话不多说了,来一起看看详细的介绍吧. Laravel Excel 在 ...
- 8 函数类型——《Swift3.0从入门到出家
Swift语言中每一个函数都有它特定的数据类型,称其为函数类型 函数类型和基本数据类型一样,可以定义变量或者常量,可以定义函数形参,也可以做为函数的返回值类型 函数类型的格式为:参数列表的数据类型—& ...