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】函数对象
转:作者:Vamei 出处:http://www.cnblogs.com/vamei 函数也是一个对象,具有属性(可以使用dir()查询).作为对象,它还可以赋值给其它对象名,或者作为参数传递. la ...
- python 在头文件添加 #include \"stdafx.h\"\r\n
import osimport shutil#-*- coding:cp936 -*-import codecsfrom sys import argv def replace_all_files(p ...
- JSON和list之间的转换
谷歌的Gson.jar: //list转换为json Gson gson = new Gson(); List<Person> persons = new ArrayList<Per ...
- String、StringBuffer、StringBuilder分析(jdk8)
以下代码只挑选了关键方法进行分析 public final class String //String类不可继承,实现了序列化 implements java.io.Serializable, Com ...
- dubbo常见报错
1. java.io.IOException: Can not lock the registry cache file C:\Users\Administrator\.dubbo\dubbo-reg ...
- SQL中合并两个表的JOIN语句
SQL里有四种JOIN语句用于根据某条件合并两个表: (INNER) JOIN: 交集 LEFT (OUTER) JOIN: 左表数据全包括,右表对应的如果没有就是NULL RIGHT (OUTER) ...
- JS返回上一页并刷新
window.history.go(-1);//返回上一页不刷新 window.location.href = document.referrer;//返回上一页并刷新
- Azure Sql Database为某个数据库创建单独的访问账户
由于SQL Management Studio对Azure SQL Database支持不完美,不能使用图形界面,因此配置数据库就会有不同的麻烦,下面是本人配置访问账户的一些经验: 1.以管理员登陆之 ...
- 深入了解ZooKeeper(二)
在上篇博客<<深入了解ZooKeeper(一)>>中我们知道了分布式协调技术.分布式锁的实现和zookeeper服务机制,接下来将进一步了解zookeeper究竟能为我们做了什 ...
- 浅析Python中bytes和str区别
本博转载自:Chown-Jane-Y的浅析Python3中的bytes和str类型 Python 3最重要的新特性之一是对字符串和二进制数据流做了明确的区分.文本总是Unicode,由str类型表示, ...