针对不同的屏幕尺寸使用不同的故事板?通用 xcode 应用
Using different storyboards for different screen sizes? universal xcode app
我提交了我的应用程序以供审核并收到错误
2.10 - iPhone Apps must also run on iPad without modification, at iPhone resolution, and at 2X iPhone 3GS resolution. We noticed that your app did not run at iPhone resolution when reviewed on iPad running iOS 9.1, which is a violation of the App Store Review Guidelines. We’ve attached screenshot(s) for your reference. Specifically, when we tap to login with Facebook on the iPad no action is produced and we are unable to get the app to advance.
我已经复制了 ipad 的第二个情节提要,其中包含信息 plist 和常规设置等。我还需要为不同的 iphone 设备制作不同的情节提要,正如您从图片中看到的那样,我的设计是自动约束不可能。
我的问题是:我是像在情节提要 1 上那样对旧的 View 控制器进行 IB 并在每个 VC 上重复代码还是我必须为新故事板创建所有新的 VC,包括应用委托?其次,我是否必须在我的应用程序委托中编写代码来说明根据屏幕尺寸或剂量使用哪个故事板 xcode 7 在信息 plist 中执行此操作?我似乎只能找到我只知道的 objc 代码 swift.
so question obj c xcode 5
你不需要不同的故事板,你只需要一个!您所要做的就是使用大小 classes。您可以在单个故事板上工作并设置不同的布局约束,甚至可以为每个大小 class.
设置不同的 UI 元素
由于我的设计限制,我无法为所有设备尺寸使用一个故事板,因此为了解决我的问题,我将这段代码添加到我的应用程序委托中:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
var bounds: CGRect = UIScreen.mainScreen().bounds
var screenHeight: NSNumber = bounds.size.height
var deviceFamily: String
var mainView: UIStoryboard!
mainView = UIStoryboard(name: "iphone35Storyboard", bundle: nil)
let viewcontroller : UIViewController = mainView.instantiateViewControllerWithIdentifier("iphone35") as UIViewController
self.window!.rootViewController = viewcontroller
if screenHeight == 480 {
deviceFamily = "iPhoneOriginal"
// Load Storyboard with name: iPhone4
var mainView: UIStoryboard!
mainView = UIStoryboard(name: "Main", bundle: nil)
let viewcontroller : UIViewController = mainView.instantiateViewControllerWithIdentifier("iphone4") as UIViewController
self.window!.rootViewController = viewcontroller
} else {
var mainView: UIStoryboard!
mainView = UIStoryboard(name: "IpadStoryboard", bundle: nil)
let viewcontroller : UIViewController = mainView.instantiateViewControllerWithIdentifier("ipad") as UIViewController
self.window!.rootViewController = viewcontroller
if screenHeight == 920 {
deviceFamily = "Pad"
// Load Storyboard with name: ipad
var mainView: UIStoryboard!
mainView = UIStoryboard(name: "IpadStoryboard", bundle: nil)
let viewcontroller : UIViewController = mainView.instantiateViewControllerWithIdentifier("ipad") as UIViewController
self.window!.rootViewController = viewcontroller
}
}
}
然后新建一个分镜,把主分镜复制粘贴到第二分镜上,调整大小。它起作用了,我对不同的 iphone 尺寸做了同样的事情。希望这对其他人有帮助。
我提交了我的应用程序以供审核并收到错误
2.10 - iPhone Apps must also run on iPad without modification, at iPhone resolution, and at 2X iPhone 3GS resolution. We noticed that your app did not run at iPhone resolution when reviewed on iPad running iOS 9.1, which is a violation of the App Store Review Guidelines. We’ve attached screenshot(s) for your reference. Specifically, when we tap to login with Facebook on the iPad no action is produced and we are unable to get the app to advance.
我已经复制了 ipad 的第二个情节提要,其中包含信息 plist 和常规设置等。我还需要为不同的 iphone 设备制作不同的情节提要,正如您从图片中看到的那样,我的设计是自动约束不可能。
我的问题是:我是像在情节提要 1 上那样对旧的 View 控制器进行 IB 并在每个 VC 上重复代码还是我必须为新故事板创建所有新的 VC,包括应用委托?其次,我是否必须在我的应用程序委托中编写代码来说明根据屏幕尺寸或剂量使用哪个故事板 xcode 7 在信息 plist 中执行此操作?我似乎只能找到我只知道的 objc 代码 swift.
so question obj c xcode 5
你不需要不同的故事板,你只需要一个!您所要做的就是使用大小 classes。您可以在单个故事板上工作并设置不同的布局约束,甚至可以为每个大小 class.
设置不同的 UI 元素由于我的设计限制,我无法为所有设备尺寸使用一个故事板,因此为了解决我的问题,我将这段代码添加到我的应用程序委托中:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
var bounds: CGRect = UIScreen.mainScreen().bounds
var screenHeight: NSNumber = bounds.size.height
var deviceFamily: String
var mainView: UIStoryboard!
mainView = UIStoryboard(name: "iphone35Storyboard", bundle: nil)
let viewcontroller : UIViewController = mainView.instantiateViewControllerWithIdentifier("iphone35") as UIViewController
self.window!.rootViewController = viewcontroller
if screenHeight == 480 {
deviceFamily = "iPhoneOriginal"
// Load Storyboard with name: iPhone4
var mainView: UIStoryboard!
mainView = UIStoryboard(name: "Main", bundle: nil)
let viewcontroller : UIViewController = mainView.instantiateViewControllerWithIdentifier("iphone4") as UIViewController
self.window!.rootViewController = viewcontroller
} else {
var mainView: UIStoryboard!
mainView = UIStoryboard(name: "IpadStoryboard", bundle: nil)
let viewcontroller : UIViewController = mainView.instantiateViewControllerWithIdentifier("ipad") as UIViewController
self.window!.rootViewController = viewcontroller
if screenHeight == 920 {
deviceFamily = "Pad"
// Load Storyboard with name: ipad
var mainView: UIStoryboard!
mainView = UIStoryboard(name: "IpadStoryboard", bundle: nil)
let viewcontroller : UIViewController = mainView.instantiateViewControllerWithIdentifier("ipad") as UIViewController
self.window!.rootViewController = viewcontroller
}
}
}
然后新建一个分镜,把主分镜复制粘贴到第二分镜上,调整大小。它起作用了,我对不同的 iphone 尺寸做了同样的事情。希望这对其他人有帮助。