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 (已经 ...
随机推荐
- Python正则表达式------进阶
Python正则表达式 正则表达式是一个特殊的字符序列,它能帮助你方便的检查一个字符串是否与某种模式匹配. Python 自1.5版本起增加了re 模块,它提供 Perl 风格的正则表达式模式. re ...
- 转:Hive性能优化之ORC索引–Row Group Index vs Bloom Filter Index
之前的文章<更高的压缩比,更好的性能–使用ORC文件格式优化Hive>中介绍了Hive的ORC文件格式,它不但有着很高的压缩比,节省存储和计算资源之外,还通过一个内置的轻量级索引,提升查询 ...
- Linux 下硬链接和软链接的说明
Linux 链接分两种,一种被称为硬链接(Hard Link),另一种被称为符号链接(Symbolic Link).默认情况下,ln 命令产生硬链接. 硬连接 硬连接指通过索引节点来进行连接.在 Li ...
- 依赖注入和Guice理解
理解依赖注入,这篇文章写得非常好,结合spring的依赖注入分析的. http://blog.csdn.net/taijianyu/article/details/2338311/ 大体的意思是: 有 ...
- New Concept English three (30)
27W/m 32 words the death of ghost For years, villagers believed that Endley Farm was hunted. The far ...
- Could not publish to the server.Please assign JRE to the server
1.错误描述 2.错误原因 由错误提示可知,是Tomcat未绑定JRE,导致报错 3.解决办法 (1)删除新建Tomcat (2)重新新建一个Tomcat,配置好Tomcat路径和JRE路径
- matlab将矩阵写入文件
% %% date: 5/5/2017 % %% Author: Congbo Ma, Hu Wang % % write matrix to file function wrt_mat_to_fil ...
- findContours()的使用崩溃问题
之前用的好好的,不知咱弄得就突然崩溃.然后网上搜了半天. 各种试,不行. 有一种改变代码方式的做法,可行,但是心里用着很是不爽.vector<vector<Point>>con ...
- mac/linux ssh 免密码登陆配置及错误处理
先说一下,mac 和linux 的设置方法是一样的 一般做法可以参照http://www.tuicool.com/articles/i6nyei 第一步:生成密钥.在终端下执行命令: ssh-kege ...
- 2017年--10年java大神告诉你开发最常用的百分之二十的技术有哪些?
首先题主说的20%我不知道从哪方面去理解.接下来我会将自己多年来工作中会经常使用到的技术列出来. 1.html.css 2.java工作原理(jvm) 3.java语法.数据结构和算法 4.java语 ...