关于界面底侧或者左右侧出侧一条空白(statusbar的高度问题) 20 pixel blank at bottom of screen
来源:互联网 发布:淘宝 评价 期限 编辑:程序博客网 时间:2024/06/05 00:13
G了半天,才找到点线索,原因:
Adding the root view to your UIWindow can be complicated since the window always underlaps the status bar. The frame of your root view must therefore be reset to [[UIScreen mainScreen] applicationFrame]
to prevent it from underlapping the status bar as well. We normally don't have to worry about this because UIViewController modifies the frame for us... except when it doesn't. Here's the deal:
- If you create your view controllerand its view in the same NIB, and younest the view underneath the viewcontroller, it will adjust the view's frame automatically.
- If you create your view controller andits view in the same NIB, but youconnect the view to the viewcontroller through the controller'sview outlet rather than nesting it, the controller will not adjust the view's frame automatically.
- If you create your view controller in one NIB, and you connect it to a view defined in a detached NIB by setting the view controller's "NIB Name" property in IB, it will adjust the view's frame automatically, but only if you also have "Resize view from NIB" checked.
- If you create your view controller by calling -initWithNibName:bundle:, it will not adjust the view's frame automatically.
- UITabBarController expects its view to be added as the root view of the window, and therefore always adjusts its own view's frame to match the application frame automatically. (As a result you'll notice a weird 20 pixel gap if you ever add a UITabBarController's view as a subview of anything other than the window.)
I guess Apple figured that -initWithNibName:bundle: wouldn't typically be used to create the window's root view, so it doesn't adjust the frame in your case. Resizing it manually as you have done is fine, and is in fact recommended in the View Controller Programming Guide for iPhone OS, but you should really use [[UIScreen mainScreen] applicationFrame]
since the status bar isn't always 20 pixels tall (e.g. it's taller when you're on a phone call.)
解决办法:
CGRect rct = loginController.view.bounds;
rct = [[UIScreen mainScreen] applicationFrame];
[loginController setWantsFullScreenLayout:YES];
rct.origin.y = 20;
loginController.view.frame = rct;
参考链接:
http://stackoverflow.com/questions/2247647/offset-on-uiwindow-addsubview
http://stackoverflow.com/questions/2166718/the-old-display-shifts-down-after-modal-view-controller-issue
- 关于界面底侧或者左右侧出侧一条空白(statusbar的高度问题) 20 pixel blank at bottom of screen
- SlidingMenu左滑菜单出来时空白的解决方案
- 关于“左右侧滑”集锦
- 获取statusbar的高度
- easyui tab 加载iframe 高度问题(解决iframe右侧总出两个滚条方法)
- Screen返回选择界面的问题
- Screen返回选择界面的问题
- 如何获取StatusBar的高度
- 单调栈的学习及例题(左右侧最近更大数的距离问题和直方图最大矩形问题)
- Grab the color of the pixel on screen
- blank.php 和 bottom.php
- 关于Android7.0系统使用webview遇到的一个问题(二级跳转后界面空白)
- 如何获取StatusBar的高度(Android平台)
- 如何获取StatusBar的高度(Android平台)
- Android状态栏(二):获得StatusBar的高度
- 如何获取StatusBar的高度(Android平台)
- 解决网页右侧空白的方法
- 关于 android:layout_gravity="bottom" 或者 android:layout_gravity="right" 在LinearLayout失效问题
- 生产者消费者模型与双缓冲队列
- c# 导出EXCEL
- Java 注解编程
- 烦人的java.util.concurrent锁
- TD分布式基站技术探讨
- 关于界面底侧或者左右侧出侧一条空白(statusbar的高度问题) 20 pixel blank at bottom of screen
- 消息队列(Message Queue)简介及其使用
- onInterceptTouchEvent和onTouchEvent调用时序
- 求一个数包含多少个1
- C# 5.0 - not quite there yet!
- arm中断及其处理
- 如何将一维数组借助指针复制到另一个数组,并输出新数组?
- WEB后台定时任务服务类及实现 源代码
- 几种搜索引擎算法研究