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 步:

第 2 步:

谁能告诉我为什么会出现这个奇怪的问题以及相关的解决方案。

同样的问题也出现在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。