关于界面底侧或者左右侧出侧一条空白(statusbar的高度问题) 20 pixel blank at bottom of screen

本文主要是介绍关于界面底侧或者左右侧出侧一条空白(statusbar的高度问题) 20 pixel blank at bottom of screen,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

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的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/418002

相关文章

SpringBoot启动报错的11个高频问题排查与解决终极指南

《SpringBoot启动报错的11个高频问题排查与解决终极指南》这篇文章主要为大家详细介绍了SpringBoot启动报错的11个高频问题的排查与解决,文中的示例代码讲解详细,感兴趣的小伙伴可以了解一... 目录1. 依赖冲突:NoSuchMethodError 的终极解法2. Bean注入失败:No qu

MySQL新增字段后Java实体未更新的潜在问题与解决方案

《MySQL新增字段后Java实体未更新的潜在问题与解决方案》在Java+MySQL的开发中,我们通常使用ORM框架来映射数据库表与Java对象,但有时候,数据库表结构变更(如新增字段)后,开发人员可... 目录引言1. 问题背景:数据库与 Java 实体不同步1.1 常见场景1.2 示例代码2. 不同操作

如何解决mysql出现Incorrect string value for column ‘表项‘ at row 1错误问题

《如何解决mysql出现Incorrectstringvalueforcolumn‘表项‘atrow1错误问题》:本文主要介绍如何解决mysql出现Incorrectstringv... 目录mysql出现Incorrect string value for column ‘表项‘ at row 1错误报错

如何解决Spring MVC中响应乱码问题

《如何解决SpringMVC中响应乱码问题》:本文主要介绍如何解决SpringMVC中响应乱码问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录Spring MVC最新响应中乱码解决方式以前的解决办法这是比较通用的一种方法总结Spring MVC最新响应中乱码解

pip无法安装osgeo失败的问题解决

《pip无法安装osgeo失败的问题解决》本文主要介绍了pip无法安装osgeo失败的问题解决,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一... 进入官方提供的扩展包下载网站寻找版本适配的whl文件注意:要选择cp(python版本)和你py

解决Java中基于GeoTools的Shapefile读取乱码的问题

《解决Java中基于GeoTools的Shapefile读取乱码的问题》本文主要讨论了在使用Java编程语言进行地理信息数据解析时遇到的Shapefile属性信息乱码问题,以及根据不同的编码设置进行属... 目录前言1、Shapefile属性字段编码的情况:一、Shp文件常见的字符集编码1、System编码

Spring MVC使用视图解析的问题解读

《SpringMVC使用视图解析的问题解读》:本文主要介绍SpringMVC使用视图解析的问题解读,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录Spring MVC使用视图解析1. 会使用视图解析的情况2. 不会使用视图解析的情况总结Spring MVC使用视图

Redis解决缓存击穿问题的两种方法

《Redis解决缓存击穿问题的两种方法》缓存击穿问题也叫热点Key问题,就是⼀个被高并发访问并且缓存重建业务较复杂的key突然失效了,无数的请求访问会在瞬间给数据库带来巨大的冲击,本文给大家介绍了Re... 目录引言解决办法互斥锁(强一致,性能差)逻辑过期(高可用,性能优)设计逻辑过期时间引言缓存击穿:给

Java程序运行时出现乱码问题的排查与解决方法

《Java程序运行时出现乱码问题的排查与解决方法》本文主要介绍了Java程序运行时出现乱码问题的排查与解决方法,包括检查Java源文件编码、检查编译时的编码设置、检查运行时的编码设置、检查命令提示符的... 目录一、检查 Java 源文件编码二、检查编译时的编码设置三、检查运行时的编码设置四、检查命令提示符

Jackson库进行JSON 序列化时遇到了无限递归(Infinite Recursion)的问题及解决方案

《Jackson库进行JSON序列化时遇到了无限递归(InfiniteRecursion)的问题及解决方案》使用Jackson库进行JSON序列化时遇到了无限递归(InfiniteRecursi... 目录解决方案‌1. 使用 @jsonIgnore 忽略一个方向的引用2. 使用 @JsonManagedR