user1754580
user1754580

Reputation:

How to Make app run on different devices of iOS

I am upgrading my app as per iPhone 5 method and got the way but just need help regarding the following point:

How do I use an if else condition to make the app choose the .xib file when made to run on different iPhones, especially iPhone 5?

Upvotes: 2

Views: 131

Answers (3)

Pawan Sharma
Pawan Sharma

Reputation: 3334

If you want to know the underlying device is iPhone 5 or not use the below code:

if ([UIScreen mainScreen].bounds.size.height == 568)
{
// Write whatever you want here.
NSLog(@"Hello from iPhone5");
}

Upvotes: 0

Tommy Devoy
Tommy Devoy

Reputation: 13549

        if(UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPad)
{//do iPad stuff
}

        if(UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPhone)
{//do iPhone stuff
}

And for images, you can look up the naming conventions on the apple dev site. I believe the iPhone 5 is used with the "[email protected]" ending. The iPad is with the "~ipad.png" and "@2x ~ipad.png". The 2x is for retina displays.

Upvotes: 1

Beltalowda
Beltalowda

Reputation: 4678

You should able to utilize autoresizing masks and/or autolayout in Interface Builder to achieve this without the need for creating an entirely new xib file for each iPhone device form factor.

Upvotes: 1

Related Questions