为不同的屏幕尺寸使用不同的情节提要吗?通用Xcode应用 [英] Using different storyboards for different screen sizes? universal xcode app

查看:124
本文介绍了为不同的屏幕尺寸使用不同的情节提要吗?通用Xcode应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将我的应用提交了审核,并收到错误

I submitted my app for review and got the error

2.10-iPhone应用程序还必须在iPad上运行且未经修改,并且必须为iPhone分辨率和2X iPhone 3GS分辨率.我们注意到,在运行iOS 9.1的iPad上进行审核时,您的应用程序未以iPhone分辨率运行,这违反了《 App Store审核指南》.我们随附了屏幕截图,供您参考.具体来说,当我们点击以在iPad上使用Facebook登录时,不会产生任何动作,因此我们无法使该应用前进.

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.

我已使用信息plist和常规设置等为ipad复制了第二个情节提要.我还需要为不同的iphone设备制作不同的情节提要,如您从图像中看到的那样,在没有自动约束的情况下,我的设计是不可能的.

I have copied second storyboard for ipad with the info plist and general settings etc. I also need to make different storyboards for different iphone devices as you can see from the image my design is not possible with auto constraints.

我的问题是什么:我是像在情节提要1上一样,只对旧的View控制器进行IB操作,并在每个VC上复制代码吗?还是必须为新的VC创建所有新的VC?故事板,包括应用程序委托?其次,我是否必须在我的应用程序委托中编写代码以说明要使用哪个情节提要,具体取决于屏幕尺寸或剂量xcode 7,请在信息plist中执行此操作?我似乎只能找到我只知道迅速的objc代码.

What my question is: do I just IB to the old View controllers the same way I did on storyboard 1 and duplicate code on each VC or do I have to create all new VCs for the new storyboard including app delegate? Secondly do I have to write code in my app delegate to state which storyboard to use depending on screen size or dose xcode 7 do this in info plist? All I can seem to find is objc code I only know swift.

请问obj c xcode 5

链接ipad和主情节提要

推荐答案

由于设计上的限制,我无法在所有设备尺寸上使用一个故事板,因此为了解决我的问题,我将此代码添加到了我的应用程序委托中:

I couldn't use one storyboard for all device sizes due to restrictions in my design so to solve my question I added this code to my app 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
        }
    }
}

然后创建一个新的情节提要,将主情节提要复制并粘贴到第二个情节提要中,并调整大小.它的工作原理是我针对不同的iPhone尺寸进行了相同的操作.希望这对其他人有帮助.

And then created a new storyboard, copied and pasted the main storyboard onto the second storyboard and adjusted the sizes. And it worked i did the same then for the different iphone sizes. Hope this helps someone else.

这篇关于为不同的屏幕尺寸使用不同的情节提要吗?通用Xcode应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆