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 UIKitclass 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方法中
随机推荐
- docker学习笔记13:Dockerfile 指令 WORKDIR介绍
Dockerfile中的WORKDIR指令用于指定容器的一个目录, 容器启动时执行的命令会在该目录下执行. 相当于设置容器的工作目录了.我们来看一个dockerfile文件 #test FROM ub ...
- android jsonarray
Json数组是子元素的有序集合,每个子元素都有一个下标,可以根据下标操纵Json数组的子元素.类JsonArray是bantouyan-json库对Json数组的抽象,提供操纵Json数组的各种方法. ...
- BZOJ 2287: 【POJ Challenge】消失之物( 背包dp )
虽然A掉了但是时间感人啊.... f( x, k ) 表示使用前 x 种填满容量为 k 的背包的方案数, g( x , k ) 表示使用后 x 种填满容量为 k 的背包的方案数. 丢了第 i 个, 要 ...
- netbeans 将项目打包生成单个可执行的 jar
原文:netbeans 打包生成 jar 文件页里找到build.xml文件,打开在</project>前 加入以下代码保存之 <target name="package- ...
- C/C++ qsort()快速排序用法
void qsort (void* base, size_t num, size_t size, int (*compar)(const void*,const void*));头文件stdlib.h ...
- 基于visual Studio2013解决C语言竞赛题之0809链表排序
题目
- Android4.2以及最新SDK的尝鲜使用
谷歌已经公布了Android4.2,而且也对应的更新了SDK到4.2.事实上最基本的是谷歌这次帮开发人员把eclipse.ADT.SDK整合 到了一起,我们仅仅须要下载一个ADT Boundle,就能 ...
- Android 应用程序签名
本文主要介绍Android应用程序签名的相关理论知识以及怎样公布Android应用程序. 1.签名的概念 为大家所熟知的日常生活中的签名,它是代表某个人的特殊标记,用于唯一标识某个人.而Android ...
- oracle exp实例
exp nam/pwd@ip:1521:databasename log=/tmp/export.log file=/tmp/oracle_database.dmp ./exp cmsuser/x ...
- RedHat Linux 5.5安装JDK+Tomcat并部署Java项目
与大家分享下RedHat Linux 5.5安装JDK+Tomcat并部署Java项目的步骤,希望对大家有用. 1.下载并安装jdk 虚拟机中安装RedHat Linux 5.5 64位企业版, 这里 ...