Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using different storyboards for different screen sizes? universal xcode app

I submitted my app for review and got the error

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.

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.

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

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.

so question obj c xcode 5

link ipad and main storyboard

like image 435
Grace Avatar asked Dec 15 '22 10:12

Grace


1 Answers

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
        }
    }
}

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.

like image 161
Grace Avatar answered Dec 26 '22 09:12

Grace