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 (已经 ...
随机推荐
- 【scala】继承
Scala中的继承与Java有着显著的不同. 抽象类abstract class abstract class Car{//抽象类 val carBrand:String;//抽象字段,一个没有被初始 ...
- 【python】self用法详解
在介绍Python的self用法之前,先来介绍下Python中的类和实例我们知道,面向对象最重要的概念就是类(class)和实例(instance). 类是抽象的模板,比如学生这个抽象的事物,可以用一 ...
- 图解 ASP.NET Core开发环境准备
2016年6月28日微软宣布发布 .NET Core 1.0.ASP.NET Core 1.0 和 Entity Framework Core 1.0. .NET Core是微软在两年前发起的开源跨平 ...
- js获取一周的日期范围
function getWeek() { this.nowTime = new Date(); this.init = function() { this.dayInWeek = this.nowTi ...
- LeetCode OJ:Linked List Cycle II(循环链表II)
Given a linked list, return the node where the cycle begins. If there is no cycle, return null. Note ...
- antd-iconfont for inner network
npm install antd-iconfont --save npm install less less-loader --save-dev webpack.config.js const pat ...
- New Concept English three (42)
21 33 Cave exploration, or pot-holing, as it has come to be known, is a relatively new sport. Perhap ...
- 关于SQL Sever连接问题
错误: 与 SQL Server 建立连接时出现与网络相关的或特定于实例的错误.未找到或无法访问服务器.请验证实例名称是否正确并且 SQL Server 已配置为允许远程连接. (provider: ...
- css 中 overflow: hidden清楚浮动的真正原因
1. 先上一段代码清楚浮动的代码, 外层ul设置overflow为hidden, 内层li设置float为left左浮动 <!DOCTYPE html> <html> < ...
- HihoCoder 1183 : 连通性一·割边与割点(模板)
连通性一·割边与割点 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 还记得上次小Hi和小Ho学校被黑客攻击的事情么,那一次攻击最后造成了学校网络数据的丢失.为了避免再次 ...