Swift - whose view is not in the window hierarchy 问题解决方法
1
|
2015 - 03 - 10 09 : 55 : 34.197 Test[ 1140 : 29622 ] Warning: Attempt to present <UIAlertController: 0x7c95ca20 > on <Test.ViewController: 0x7a6afc60 > whose view is not in the window hierarchy! |
解决办法:原来的调用代码是写在viewDidLoad方法中,这个表示视图加载完毕。我们应该把方法调用放到viewDidApper中,这个是UIViewController对象的视图已经加入到窗口时调用。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
import UIKit class ViewController : UIViewController , UIActionSheetDelegate { override func viewDidLoad() { super .viewDidLoad() } override func viewDidAppear(animated: Bool ){ super .viewDidAppear(animated) var alertController = UIAlertController (title: "系统提示" , message: "您确定要离开hangge.com吗?" , preferredStyle: UIAlertControllerStyle . Alert ) var cancelAction = UIAlertAction (title: "取消" , style: UIAlertActionStyle . Cancel , handler: nil ) var okAction = UIAlertAction (title: "好的" , style: UIAlertActionStyle . Default , handler: nil ) alertController.addAction(cancelAction) alertController.addAction(okAction) self .presentViewController(alertController, animated: true , completion: nil ) } override func didReceiveMemoryWarning() { super .didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } } |
Swift - whose view is not in the window hierarchy 问题解决方法的更多相关文章
- swift一次 Attempt to present on whose view is not in the window hierarchy的解决方法
做的是二维码扫描,扫描后识别为URL的话就跳转到webview 加载网页,用的是代理传值的方式.扫描到了 值传递到主页 扫描窗体退出,检测值是否是http://开头 是网页就跳转. 问题出在传值到主界 ...
- IOS 开发中 Whose view is not in the window hierarchy 错误的解决办法
在 IOS 开发当中经常碰到 whose view is not in the window hierarchy 的错误,该错误简单的说,是由于 "ViewController" ...
- whose view is not in the window hierarchy
参考:http://www.jianshu.com/p/9e90cb866fdf 在做界面跳转的时候,我们经常会用到这两个函数 func dismissViewControllerAnimated(f ...
- 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 ...
- iOS开发出错whose view is not in the window hierarchy!的解决
大熊猫猪·侯佩原创或翻译作品.欢迎转载,转载请注明出处. 如果觉得写的不好请多提意见,如果觉得不错请多多支持点赞.谢谢! hopy ;) 一个简单的单窗口App在运行时出现错误: 2016-04-07 ...
- 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 ...
- iOS whose view is not in the window hierarchy!
解决方法: viewController只Load完毕,没有Appear,此时应该将语句转移到ViewDidAppear方法中
随机推荐
- NOI2015 寿司晚宴
今年NOI确实是在下输了.最近想把当时不会做的题都写一下. 题意 从2到n(500)这些数字中,选若干分给A,若干分给B,满足不存在:A的某个数和B的某个数的GCD不等于1. 对于寿司晚宴这题,标准解 ...
- JAVAC 命令使用方法
结构 javac [ options ] [ sourcefiles ] [ @files ] 參数可按随意次序排列. options 命令行选项. sourcefiles 一个或多个要编译的源文件( ...
- 结构体中使用#define定义宏
struct hostent { char *h_name; /* official name of host */ char **h_aliases; /* ...
- Android模拟器的文件目录介绍
文件存放在 .avd文件夹下 .ini为对应的配置文件 打开.avd文件夹 *.lock文件夹保存的是模拟器的一下数据,当模拟器正常关闭时这些文件夹都会被自动删除. 当模拟器无法开启的时候可以 ...
- JQuery - 提交表单
[JavaScript] JQuery异步提交表单与文件上传 Jquery.form.js是一个可以异步提交表单及上传文件的插件. 文档地址:http://jquery.malsup.com/form ...
- 常见的transformation 和 Action
常见transformation map 将RDD中的每个元素传入自定义函数,获取一个新的元素,然后用新的元素组成新的RDD filter 对RDD中每个元素进行判断,如果返回true则保留,返回fa ...
- 用来解析,格式化,存储和验证国际电话号码:libphonenumber
用来解析,格式化,存储和验证国际电话号码:libphonenumber libphonenumber是Google的公共Java.C++和Javascript库用来解析,格式化,存储和验证国际电话号码 ...
- Java的位运算符具体解释实例——与(&)、非(~)、或(|)、异或(^)
位运算符主要针对二进制,它包含了:“与”.“非”.“或”.“异或”.从表面上看似乎有点像逻辑运算符,但逻辑运算符是针对两个关系运算符来进行逻辑运算,而位运算符主要针对两个二进制数的位进行逻辑运算.以下 ...
- c语言:union,大小端
union: 不允许只用联合变量名作赋值或其它操作. 也不允许对联合变量作初始化赋值,赋值只能在程序中进行. 小端存储: 以字节为单位,低存低,高存高. 任何数据在内存中都是以二进制(1或着0)顺序存 ...
- bottle-session 0.2 : Python Package Index
bottle-session 0.2 : Python Package Index bottle-session 0.2 Download bottle-session-0.2.tar.gz Redi ...