当我想从一个VC跳转到另一个VC的时候,一般会用

- (void)presentViewController:(UIViewController *)viewControllerToPresent animated: (BOOL)flag completion:(void (^)(void))completion;当然也可以用导航push。

有时会遇到了此类警告:Warning: Attempt to present on whose view is not in the window hierarchy!

原因:页面跳转必须在viewDidLoad和viewDidAppear之后才能进行。

解决办法:必须确保页面跳转要在view load完毕之后进行。

第一种:通过延时来等待view Load执行结束,但是这个方法在时间上不好把握

第二种:在viewDidLoad里用

[selfperformSelectorOnMainThread:@selector(login)withObject:nilwaitUntilDone:NO];

把页面跳转的代码写进函数里,然后将 waitUntilDone 设为NO

Warning: Attempt to present on whose view is not in the window hierarchy!的更多相关文章

  1. swift一次 Attempt to present on whose view is not in the window hierarchy的解决方法

    做的是二维码扫描,扫描后识别为URL的话就跳转到webview 加载网页,用的是代理传值的方式.扫描到了 值传递到主页 扫描窗体退出,检测值是否是http://开头 是网页就跳转. 问题出在传值到主界 ...

  2. Warning: Attempt to present on whose view is not in模态跳转问题

    错误分析:            controller A present controller B ,前提是A的view要存在,如果不存在,就会报这个错.   解决方法:             将 ...

  3. 错误: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 ...

  4. Warning: Attempt to present A on B whose view is not in the window hierarchy!

    昨天写豆瓣发广播Demo的时候,为了写Demo的简单,就使用了Storyboard,结果执行视图跳转时遇到了这个问题: Warning: Attempt to present <UINaviga ...

  5. Warning: Attempt to present * on * which is already presenting *

    Warning: Attempt to present (要被presented的控制器)  on (哪个控制器来presenting) which is already presenting (已经 ...

  6. Attempt to present <TestViewController2: 0x7fd7f8d10f30> on <ViewController: 0x7fd7f8c054c0> whose view is not in the window hierarchy!

    当 storyboard里面的 按钮 即连接了 类文件里面的点击方法  又  连接了   storyboard里 另一个  控制器的  modal 就会出现类似Attempt to present & ...

  7. Swift - whose view is not in the window hierarchy 问题解决方法

    问题现象:想在页面初始化的时候,使用self.presentViewController方法弹出个告警提示框UIAlertController.但行后报了个如下告警,同时告警框也出不来. 1 2015 ...

  8. iOS开发出错whose view is not in the window hierarchy!的解决

    大熊猫猪·侯佩原创或翻译作品.欢迎转载,转载请注明出处. 如果觉得写的不好请多提意见,如果觉得不错请多多支持点赞.谢谢! hopy ;) 一个简单的单窗口App在运行时出现错误: 2016-04-07 ...

  9. whose view is not in the window hierarchy

    参考:http://www.jianshu.com/p/9e90cb866fdf 在做界面跳转的时候,我们经常会用到这两个函数 func dismissViewControllerAnimated(f ...

随机推荐

  1. 笔记:Html.Partial和Html.Action

    1.带有Render的方法返回值是void,在方法内部进行输出:不带的返回值类型为MvcHtmlString,所以只能这样使用:@Html.Partial 对应 @{Html.RenderPartia ...

  2. CentOS上安装SQL Server vNext CTP1

    今天微软正式发布上SQL Server 2016 SP1,根据以往的SP1定律,可以在生产环境上使用了.打了SP1的标准版将具有企业版几乎所有的的功能.只有RAM 超过128GB或者超过24核心或者超 ...

  3. 关于Html与css的一些解释

    一.简单介绍 1.html,是hyper text markup language的缩写,中文为“超文本标记语言”. 2.html不是编程语言而是一种标记语言. 二.标签与元素 1.html标签:如& ...

  4. ASP.NET MVC案例——————拦截器

    摘要      本文将对“MVC公告发布系统”的发布公告功能添加日志功能和异常处理功能,借此来讨论ASP.NET MVC中拦截器的使用方法. 一个小难题      我们继续完善“MVC公告发布系统”, ...

  5. .Net语言 APP开发平台——Smobiler学习日志:如何仿微信朋友圈的消息样式?

    最前面的话:Smobiler是一个在VS环境中使用.Net语言来开发APP的开发平台,也许比Xamarin更方便 一.目标样式 我们要实现上图中的效果,需要如下的操作: 1.从工具栏上的”Smobil ...

  6. 【Win10开发】关于汉堡菜单-SplitView的用法

    SplitView(汉堡菜单)是win10新加的一种控件,顾名思义,其实就是将视图分割成两部分,废话不多说,下面来介绍一下SplitView的基本用法. 首先介绍几个SplitView经常用到的属性. ...

  7. 【SQL】小心字符串拼接导致长度爆表

    请看代码: DECLARE @max VARCHAR(max) SET @max='aaa...' --这里有8000个a +'bb' --连接一个varchar常量或变量 SELECT LEN(@m ...

  8. OC基础数据类型-NSData-NSMutableData-NSString

    NSData和NSMutableData存储的是二进制数据,在文件操作,网络,以及核心图形图像中使用较广泛.NSData创建后不可以再修改,NSMutableData可以再次修改. 1.NSStrin ...

  9. 背水一战 Windows 10 (6) - 控件 UI: 字体的自动继承的特性, Style, ControlTemplate

    [源码下载] 背水一战 Windows 10 (6) - 控件 UI: 字体的自动继承的特性, Style, ControlTemplate 作者:webabcd 介绍背水一战 Windows 10 ...

  10. jquery可见性选择器(匹配所有隐藏的元素)

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...