ios - 针对不同的屏幕尺寸使用不同的 Storyboard?通用 xcode 应用程序

标签 ios xcode ipad xcode7 ios-universal-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 复制了第二个 Storyboard,其中包含信息 plist 和常规设置等。我还需要为不同的 iphone 设备制作不同的 Storyboard,正如您从图像中看到的那样,我的设计无法使用自动约束。

if you look at the age it is not able to go in the box in the last 3 only the first

我的问题是:我是像在 Storyboard 1 上那样对旧的 View Controller 进行 IB 并在每个 VC 上复制代码,还是我必须为新的创建所有新的 VC Storyboard包括应用程序委托(delegate)?其次,我是否必须在我的应用程序委托(delegate)中编写代码来说明根据屏幕尺寸使用哪个 Storyboard ,或者 xcode 7 在信息 plist 中执行此操作?我似乎只能找到我只知道 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/

相关文章:

ios - 某些 iOS 应用商店页面如何具有自定义背景和样式?

iPhone - 如何检测 iPhone 版本?

ios - Core Graphics - 我的三角形/圆弧太尖了

iphone - 如何在 XCode 4.3 中更有效地组织我的项目、库等?

xcode - 在 swift 中按枚举的值对对象数组进行排序

ios - 对多个 Xcode 目标使用相同的版本号 Info.plist

ios - UIPopoverController 在运行 iOS 5.0.1 的 iPad 上崩溃?

iphone - 如何获取UIImagePickerController拾取的图像的原始文件名?

ios - Swift Segue 问题

ios - UICollectionView 的 viewDidLoad 大小不正确