【发布时间】:2015-09-13 20:17:35
【问题描述】:
我在我的应用程序中添加了自动布局,它非常适合 4"、4.7" 和 5.5" 屏幕。但是,当我在 3.5" (iPhone 4S) 上对其进行测试时,它很混乱。很多物体都在彼此之上。我能做些什么 ?将应用程序上传到 iTunes Connect 时,有没有办法排除 iPhone 4S?如果我的应用程序仍然支持 iOS 9,它不适用于 iPhone 4S,我的应用程序会被拒绝吗? (使用 Xcode 7 GM)
编辑:
我为 3.5 英寸制作了另一个名为“iPhone35”的故事板,并将此代码添加到 AppDelegate.swift 中的应用程序函数中,但它总是打开 Main.storyboard,它适用于 4 英寸及以上的屏幕尺寸,即使我选择iPhone 4S 模拟器。
let theBounds = UIScreen.mainScreen().bounds
let heightDevice = theBounds.size.height
if heightDevice == 480 {
let wantedStoryboard = UIStoryboard(name: "iPhone35", bundle: nil)
let vc = wantedStoryboard.instantiateViewControllerWithIdentifier("MainPage")
let rootViewController = self.window!.rootViewController
rootViewController?.presentViewController(vc, animated: false, completion: nil)
} else {
let wantedStoryboard = UIStoryboard(name: "Main", bundle: nil)
let vc = wantedStoryboard.instantiateViewControllerWithIdentifier("MainPage")
let rootViewController = self.window!.rootViewController
rootViewController?.presentViewController(vc, animated: false, completion: nil)
}
我该怎么办?
【问题讨论】:
-
您的应用需要在 iPhone 4S 上运行。此外,如果您的应用程序不是通用的,它将使用 iPhone 4S 的宽高比在 iPad 上运行。
-
那我该怎么办?我可以为 4S 创建一个不同的 Main.storyboard 吗?
-
一种方法是为 4S 创建不同的 Storyboard 文件。搜索 SO 以了解如何做到这一点。另一个是修复您的约束,以便它们在较短的屏幕上正常工作。没有看到你的屏幕和你的限制,SO 成员不可能帮助你。
-
谢谢瓦卡瓦玛。我已经在做这件事了。谢谢你的回复。完成后会回复您并向 AppDelegate.swift 添加几行代码
-
@vacawama ,我制作了另一个名为“iPhone35”的故事板,我在编辑部分尝试了代码,但它不起作用,该怎么办?
标签: iphone autolayout iphone-4