文档章节

presentViewController:animated:completion:的特殊之处

yoyoso
 yoyoso
发布于 2015/02/28 14:52
字数 224
阅读 1822
收藏 0

原型:

- (void)presentViewController:(UIViewController *)viewControllerToPresent animated:(BOOL)flag completion:(void (^)(void))completion


描述:

Presents a view controller modally.
  In a horizontally compact environment, the presented view is always full screen. In a horizontally regular environment, the presentation depends on the value in the modalPresentationStyle property.
    This method sets the presentedViewController property to the specified view controller, resizes that view controller'€™s view based on the presentation style and then adds the view to the view hierarchy. The view is animated onscreen according to the transition style specified in the modalTransitionStyle property of the presented view controller.
The completion handler is called after the viewDidAppear: method is called on the presented view controller.

注意上面红色文字的地方。

一般来说,页面跳转必须在viewDidLoad和viewDidAppear之后才能进行,如果是在presentViewController:animated:completion:的completion中跳转,可以确保页面跳转是在viewDidAppear之后进行的。否则,就会有可能提示Warning: 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!的解决方案


© 著作权归作者所有

共有 人打赏支持
yoyoso
粉丝 48
博文 129
码字总数 45109
作品 0
南京
高级程序员
私信 提问
presentViewController显示方式的窗口,没有导航栏的解决方法

ViewController *Controller = [[ViewController alloc] init]; UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:Controller]; [self presentVi......

卓行天下
2017/08/24
0
0
例如有两个分别为A,B的viewcontroller ,然后每隔5秒钟重复切换两个viewcontroller。

+ (NSTimer *)scheduledTimerWithTimeInterval:(NSTimeInterval)ti target:(id)aTarget selector:(SEL)aSel ... -(void)screenFun:(NSTimer *)timer { [NSTimer scheduledTimerWithTimeInter......

什科夫
2013/07/26
125
0
modal的样式及 半透明控制器效果

modal出半透明的控制器: UIViewController * maskVC = [[UIViewController alloc] init]; //设置页面的透明度 maskVC.view.backgroundColor = [UIColor colorWithFullRed:0 green:0 blue:0......

biyu6
2016/05/26
78
0
控制器中添加控制器的常见方法

控制器中添加控制器的常见方法: 1 添加子控制器:addChildViewController: 2 modal出控制器: presentViewController:<#(nonnull UIViewController *)#> animated:<#(BOOL)#> completion:<#......

奋斗的青春年华
2016/08/30
4
0
NSInvalidArgumentException :Application tried t...

违背了一个原则: Apple expects you to treat their UI elements in a certain way. 即一个东西必须明确它的作用 在使用storyboard的 prepareForSegue:(UIStoryboardSegue *)segue sender:......

孔俊
2013/08/17
0
0

没有更多内容

加载失败,请刷新页面

加载更多

CentOS7下Tomcat启动慢的原因及解决方案

CentOS7下Tomcat启动慢的原因及解决方案 现象   在一次CentOS 7系统中安装Tomcat,启动过程很慢,需要几分钟,经过查看日志,发现耗时在这里:是session引起的随机数问题导致的。Tocmat的S...

linjin200
17分钟前
1
0
表格单元格td设置宽度无效的解决办法

<!--如果这样设置无效,--> <td width="120">123456789000000000000</td><!--那么套个div再设置宽度就有效了。--> <td><div style="width: 60px;overflow: hidden;text-overflow: e......

SummerGao
17分钟前
1
0
06.Beetl标签函数include ---《Beetl视频课程》

本期视频实现了评论列表分页; 内容简介:使用了标签函数include完成分页抽取 一起学beetl目录:https://my.oschina.net/u/1590490?tab=newest&catalogId=6214598 作者:GK 标签函数 includ...

Gavin-King
20分钟前
2
0
Valid Anagram(leetcode242)

Given two strings s and t , write a function to determine if t is an anagram of s. Example 1: Input: s = "anagram", t = "nagaram"Output: true Example 2: Input: s = "rat", t = ......

woshixin
23分钟前
1
0
Parameter 'loginname' not found. Available parameters are [arg1, arg0, param

原来是这样写的 @Select("select * from user where login_name=#{loginName} and password=#{password}") User findWithLoginnameAndPassword(int loginName,String password); 一直报找不到......

kuchawyz
26分钟前
1
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部