iphone-6 和 iPhone 6 plus(在 Swift 和 Objective-c 两者中)视图控制器没有显示在整个屏幕上
View controller is not showing on whole screen for iphone-6 and iPhone 6 plus (in Swift and Objective-c both)
我现在遇到的奇怪错误:
如果我在应用程序中禁用自动布局并尝试处理启动屏幕,那么就会出现奇怪的错误:
第 1 步:
- 如果我只为 LaunchImage 设置 iOS-7 及更高版本的应用程序,那么一切
工作正常。但问题是我们无法设置 LaunchImage 屏幕
对于 iPhone- 6 和 iPhone 6 + (在这种情况下,将显示 1136 尺寸的图像
作为 iPhone 6 和 iPhone 6+)
的飞溅
- 而 window iPhone 5 及以上尺寸显示 320*568(对于 iPhone5 . 5s、6 和 6+)。
第 2 步:
- 如果我也为 LaunchImage 启用 iOS-8 及更高版本的应用程序并为 iPhone 6 和 6+ 设置启动,则启动工作正常。但是在 splash window 之后,大小现在会根据设备屏幕大小进行显示。由于这个原因,所有视图控制器都没有显示在整个屏幕中,因为视图控制器大小仍然显示 320*480
谁能告诉我为什么会出现这个奇怪的问题以及相关的解决方案。
同样的问题也出现在swift编程中。
这不是一个奇怪的问题。只需在 veiwDidLoad
中设置视图的背景颜色,例如 self.view.backgroundcolor = [UIColor redColor];
,您会注意到 viewController 正在使用全屏,但其他控件没有调整大小。
只需使用自动布局
Auto Layout is a system that lets you lay out your app’s user interface by creating a mathematical description of the relationships between the elements. You define these relationships in terms of constraints either on individual elements, or between sets of elements. Using Auto Layout, you can create a dynamic and versatile interface that responds appropriately to changes in screen size, device orientation, and localization.
你可以查看documentation
Here是最好的教程。
更新:
我不建议使用自动调整大小
但你仍然想在没有自动布局的情况下进行,你必须使用自动调整大小。
您没有任何其他选择。
要用户自动调整大小,请使用本教程:Handling Layout Changes Automatically Using Autoresizing Rules
希望对您有所帮助....
我想你是不是忘记在你的项目中添加启动画面 Default-568h@2x.png
你能看看我的 previous answer
最后我找到了解决这个问题的另一种方法:
只需为 7.0 及更高版本添加启动屏幕,然后您的应用程序将 运行 在 iPhone 5,5s、6 和 6+ 上相应地 运行。
为 2x 和 Retina 添加 LaunchImage。
我现在遇到的奇怪错误: 如果我在应用程序中禁用自动布局并尝试处理启动屏幕,那么就会出现奇怪的错误:
第 1 步:
- 如果我只为 LaunchImage 设置 iOS-7 及更高版本的应用程序,那么一切 工作正常。但问题是我们无法设置 LaunchImage 屏幕 对于 iPhone- 6 和 iPhone 6 + (在这种情况下,将显示 1136 尺寸的图像 作为 iPhone 6 和 iPhone 6+) 的飞溅
- 而 window iPhone 5 及以上尺寸显示 320*568(对于 iPhone5 . 5s、6 和 6+)。
第 2 步:
- 如果我也为 LaunchImage 启用 iOS-8 及更高版本的应用程序并为 iPhone 6 和 6+ 设置启动,则启动工作正常。但是在 splash window 之后,大小现在会根据设备屏幕大小进行显示。由于这个原因,所有视图控制器都没有显示在整个屏幕中,因为视图控制器大小仍然显示 320*480
谁能告诉我为什么会出现这个奇怪的问题以及相关的解决方案。
同样的问题也出现在swift编程中。
这不是一个奇怪的问题。只需在 veiwDidLoad
中设置视图的背景颜色,例如 self.view.backgroundcolor = [UIColor redColor];
,您会注意到 viewController 正在使用全屏,但其他控件没有调整大小。
只需使用自动布局
Auto Layout is a system that lets you lay out your app’s user interface by creating a mathematical description of the relationships between the elements. You define these relationships in terms of constraints either on individual elements, or between sets of elements. Using Auto Layout, you can create a dynamic and versatile interface that responds appropriately to changes in screen size, device orientation, and localization.
你可以查看documentation
Here是最好的教程。
更新:
我不建议使用自动调整大小
但你仍然想在没有自动布局的情况下进行,你必须使用自动调整大小。
您没有任何其他选择。
要用户自动调整大小,请使用本教程:Handling Layout Changes Automatically Using Autoresizing Rules
希望对您有所帮助....
我想你是不是忘记在你的项目中添加启动画面 Default-568h@2x.png 你能看看我的 previous answer
最后我找到了解决这个问题的另一种方法:
只需为 7.0 及更高版本添加启动屏幕,然后您的应用程序将 运行 在 iPhone 5,5s、6 和 6+ 上相应地 运行。
为 2x 和 Retina 添加 LaunchImage。