Search code examples
iosipadsprite-kitheightscreen-size

How do I create an if statement like the one below for iPad screen size?


I am trying to create a universal app, and I am just wondering how I write the following code to direct it to iPad version of app. Specifically what should the navtiveBounds.height be for the iPad Air and Mini. Thanks So Much :)

if UIScreen.mainScreen().nativeBounds.height == 2208 {
            println("iPhone 6+")
            let delay = SKAction.waitForDuration(1)
            let transition = SKAction.runBlock({
                let scene = Menu6Plus(size: self.size)
                self.view?.presentScene(scene)
            })

            runAction(SKAction.sequence([delay, transition]))


        }

Solution

  • You can use:

    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
        // Code for iPad!
    }
    

    Also, I believe that if you were to use the nativeBounds property to determine screen size, iPad and iPad mini would both return the same 1024-by-768 resolution. If you really need to detect if the user is running an iPad Mini at runtime, try this:

    Is it possible to detect that your iOS app is running on an iPad mini at runtime?