Iphone iOS-自动布局不适合3.5英寸屏幕
我在我的应用程序中添加了自动布局,它在4、4.7和5.5屏幕上都能完美运行。然而,当我在3.5版iPhone 4S上测试它时,它很混乱。很多对象都在彼此的上面。我能做什么?在将应用程序上传到iTunes Connect时,有没有办法排除iPhone 4S?如果它在iPhone 4S上不起作用,我的应用程序会被拒绝吗ce它仍然支持使用Xcode 7 GM的iOS 9 编辑: 我制作了另一个3.5英寸的故事板,名为iPhone35,并将此代码添加到AppDelegate.swift中的应用程序函数中,但它总是打开Main.storyboard,即使我选择了iPhone4S模拟器,它也适用于4英寸及以上的屏幕尺寸Iphone iOS-自动布局不适合3.5英寸屏幕,iphone,autolayout,iphone-4,Iphone,Autolayout,Iphone 4,我在我的应用程序中添加了自动布局,它在4、4.7和5.5屏幕上都能完美运行。然而,当我在3.5版iPhone 4S上测试它时,它很混乱。很多对象都在彼此的上面。我能做什么?在将应用程序上传到iTunes Connect时,有没有办法排除iPhone 4S?如果它在iPhone 4S上不起作用,我的应用程序会被拒绝吗ce它仍然支持使用Xcode 7 GM的iOS 9 编辑: 我制作了另一个3.5英寸的故事板,名为iPhone35,并将此代码添加到AppDelegate.swift中的应用程序函数中
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)
}
我该怎么办?所以我所做的就是将这个函数添加到AppDelegate.swift
func grabStoryBoard() -> UIStoryboard {
var storyboard: UIStoryboard
let width = UIScreen.mainScreen().width
if width == 480.0 {
storyboard = UIStoryboard(name: "iPhone35", bundle: nil)
} else {
storyboard = UIStoryboard(name: "Main", bundle: nil)
}
return storyboard
}
然后在didFinishLaunchingWithOptions函数中添加这几行
let storyboard: UIStoryboard = self.grabStoryBoard()
self.window!.rootViewController = storyboard.instantiateInitialViewController() as UIViewController?
self.window!.makeKeyAndVisible()
我还单击了新故事板第一个控制器上的初始视图控制器
之所以width==480.0,是因为我的应用程序设置为“仅横向”。你的应用程序需要与iPhone 4S配合使用。此外,如果你的应用程序不是通用的,它将使用iPhone 4S纵横比在iPad上运行。那么我该怎么办?我可以为4S创建不同的Main.storyboard吗?一种方法是创建不同的storyboard file的4S。搜索如何做到这一点。另一个是修复您的限制,使他们在较短的屏幕上正常工作。如果看不到您的屏幕和您的限制,SO成员不可能帮助您。谢谢Vacawama。我已经在做这件事了。谢谢您的回复。我完成后会回复您并向AppDelegate添加了几行代码。swift@vacawama,我制作了另一个故事板,名为iPhone35,我在编辑部分尝试了代码,但没有成功,怎么办?