Check if iPhone version running on iPad?

3 replies [Last post]
hawkwood
User offline. Last seen 6 days 2 hours ago. Offline
Joined: 19 Feb 2011

Okay this should be in the "Non Universal Binaries" section, but I didn't see one, so bear with me.

I have an app that has some different interface functionality depending on if it's an iPhone (small screen) or an iPad (big screen) and I am going to release the two versions as separate apps (business decision, please don't attack me for it). Since there is no reasonable way to block an iPhone only app from running on the iPad (compatibility mode) I'd like to know when someone is running the iPhone version and have the app show the appropriate interface.

Suggestions?

Replies

peach pellen's picture
peach pellen
User offline. Last seen 21 hours 59 min ago. Offline
Staff
Joined: 12 Apr 2011

You should be able to use the following to detect whether or not it is running on an iPad.

system.getInfo("model") == "iPad"

I see the sense in releasing two versions, I've done that more often than Universal builds :)

Peach

hawkwood
User offline. Last seen 6 days 2 hours ago. Offline
Joined: 19 Feb 2011

In my experience, system.getInfo("model") returns "iPad" when it is on the iPad device regardless of whether it's running the iPhone version or iPad version of the app. I'm looking for a way to decide which version of the app is running on the iPad, something similar to UIUserInterfaceIdiomPhone vs. UIUserInterfaceIdiomPad.

Thanks again.

mnewnam's picture
mnewnam
User offline. Last seen 5 hours 25 min ago. Offline
Joined: 10 Jan 2012

If you are going to have two separate apps, couldn't you set a variable in each app to let you know which version it is?

So for the iPhone app you would have

local appVersion = "iPhone"

and on the iPad version use

local appVersion = "iPad"

Then compare this variable with system.getInfo("model") and you will know if they are running the iPhone version on an iPad.

-Mark

Viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.