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方法中
随机推荐
- 基于visual Studio2013解决算法导论之046广度优先搜索
题目 广度优先搜索 解决代码及点评 // 图的邻接表表示.cpp : 定义控制台应用程序的入口点. // #include <iostream> #include <stac ...
- [置顶] 深入ResourceBundle
ResourceBundle是java开发中非常实用的一个类,主要用来处理应用程序多语言这样的国际化问题. 如果你的应用程序如果有国际化的需求,可以考虑使用ResourceBundle, 你要做的就是 ...
- 建立Go工作环境
最近在折腾Go语言,找了个开源项目nsq研究源代码.不过前两天不小心把系统搞挂了,这次又要重做一遍,记录一下,备忘. 准备: 1. vim+golang插件+ctags(新版本支持Go) 2. Go1 ...
- C++部分术语(Terms)
翻译自msdn,如有不妥当的地方,欢迎指正. 声明(Declaration):声明引入了一个名字以及其类型进入程序中,并没有定义一个相关的对象或者函数.然而,很多声明都作为定义使用. 定义(def ...
- 使用ant的jar任务打jar包
<?xml version="1.0" encoding="UTF-8"?> <project name="javaTest&quo ...
- pyfits例子
下面是一个读入fits文件,画积分强度图,再把某个星表里的天体画到图上的python程序. ====================================================== ...
- 09-UIKit(UICollectionViewController、UITabBarController)
目录: 一.UICollectionViewController 二.UITabBarController(标签控制器) 三.视图和试图控制器的生命周期 四.其他控件 回到顶部 一.UICollect ...
- AV_百度百科
AV_百度百科 AV(影片门类)
- 【linux驱动笔记】linux模块机制浅析
1. 模块module 操作系统分微内核和宏内核,微内核优点,可以使操作系统仅作很少的事,其它事情如网络处理等都作为应用程序来实现,微内核精简的同时,必然带来性能的下降.而linux的宏内核设 ...
- iTunes Store:隐藏和取消隐藏已购项目
使用 Mac 或 PC 上的 iTunes 来隐藏或取消隐藏已购项目. 如何隐藏已购项目 在 Mac 或 PC 上打开 iTunes. 从 Store 菜单中,选取商店 > 登录,然后输入您的 ...