关于iOS7中child viewController 的topLayoutGuide 的length错误的处理
来源:互联网 发布:js filereader文件路径 编辑:程序博客网 时间:2024/06/07 02:17
很多人可能都遇到过这种问题:把一个TabBarController压栈到一个NavigationController中后,对TabBarController的视图控制器里的视图使用自动布局,当添加一个view.top = self.topLayoutGuide.bottom后,发现view一部分被NavigationBar挡住了。这是因为在is中,TabBarViewController里面的视图控制的的topLayoutGuide的length只有20个像素,处理方法是重载viewWillLayoutSubiews方法,改变约束的constant值,如下:
为了方便,我们不再添加view.top = self.topLayoutGuide.bottom的约束,而是添加view.top = self.topLayoutGuide.top的约束:
self.topLayoutGuideConstraint = [NSLayoutConstraint constraintWithItem:view attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.topLayoutGuide attribute:NSLayoutAttributeTop multiplier:1 constant:0]; [self.view addConstraint:self.topLayoutGuideConstraint];- (void)viewWillLayoutSubviews{ [super viewWillLayoutSubviews]; self.topLayoutGuideConstraint.constant = [self.tabBarController.topLayoutGuide length];}
在viewWillLayoutSubviews调用以后,tabBarController.topLayoutGuide的lenth是状态栏的高度和导航栏的高度之和
实际上不只是tabBarController存在这种问题,child viewController和 parent viewController之间也存在这种问题
0 0
- 关于iOS7中child viewController 的topLayoutGuide 的length错误的处理
- 关于viewController的生命周期
- A child container failed during start错误的处理
- A child container failed during start错误的处理
- IOS7 中典型的tabarcontroller+navigationbarcontroller+viewcontroller组合 的一个问题解决
- 关于java中string.length()的问题
- 关于js中几个错误的处理
- 关于ViewController 生命周期的理解
- 关于laravel中key的错误cipher and / or key length are invalid
- IOS7有UINavigation时隐藏当前ViewController的UITabBar.
- 关于ios7的一切
- 关于nth-child的疑惑
- mapreduce 过程中关于 0-length 数据进入reducer 时的处理
- iOS6中关于切换(segue)viewController产生的问题
- storyboard中游离的viewcontroller
- iOS中ViewController的生命周期
- JAVA中length、length()、size()的区别
- java中length,length(),size()的…
- #define中字符串连接操作符##
- C语言指针数组
- STL系列之map(映射)
- 【国家统计局】2013年6月份-2014年5月份70个大中城市住宅销售价格变动情况
- Kali Linux Mini Documentation
- 关于iOS7中child viewController 的topLayoutGuide 的length错误的处理
- has a 和use a互相调用 值数据
- 如何下载新东方的在线视频小计-已成功crack
- 排序算法之堆排序Java版
- 剑指offer之从上往下打印二叉树
- 黑马程序员-java基础-总结的几点问题
- 黑马day11 dbcp连接池
- VS调用matlab
- LinearLayout设置 weight 无法绘制的问题