我提交了我的应用程序以供审核并收到错误消息
我已经为 ipad 复制了第二个 Storyboard,其中包含信息 plist 和常规设置等。我还需要为不同的 iphone 设备制作不同的 Storyboard,正如您从图像中看到的那样,我的设计无法使用自动约束。
我的问题是: 我是不是像在 Storyboard 1 上所做的一样,只对旧的 View Controller 进行 IB 处理,并在每个 VC 上复制代码,还是必须为新的 Storyboard创建所有新的 VC,包括应用程序委托(delegate)?其次,我是否必须在我的应用程序委托(delegate)中编写代码以根据屏幕大小或剂量 xcode 7 在信息 plist 中说明使用哪个 Storyboard?我似乎只能找到我只知道 swift 的 objc 代码。
so question obj c xcode 5
link ipad and main storyboard
最佳答案
由于我的设计限制,我无法为所有设备尺寸使用一个 Storyboard,因此为了解决我的问题,我将此代码添加到我的应用程序委托(delegate)中:
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
}
}
}
然后创建一个新的 Storyboard,将主 Storyboard复制粘贴到第二个 Storyboard并调整大小。它的工作原理我对不同的 iphone 尺寸做了同样的事情。希望这对其他人有帮助。
关于ios - 为不同的屏幕尺寸使用不同的 Storyboard?通用 xcode 应用程序,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/34048543/