2

How to make universal app for iphone and ipad. How we detect the device whether it is for iPhone or iPad?

er.mobileapp
  • 1,287
  • 4
  • 15
  • 21

3 Answers3

2

The easiest way would be using UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad and UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone.

Anh
  • 6,523
  • 7
  • 46
  • 59
1

in Xcode 3

select your target in Xcode, right-click and use the “Upgrade Current Target for iPad…” command.

in Xcode 4

click on the project and go to the target. In Summary tab, change Device to Universal.

I used

UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad

for detecting iPad.

saturngod
  • 24,649
  • 17
  • 62
  • 87
  • and if i want to detect the iPod and iPhone then: UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomiPod and vice versa? – er.mobileapp May 09 '11 at 04:56
0

Personnally, I used this method in my appdelegate

+ (BOOL)isPad
{
    NSLog(@"--------- %@ ---------", [[UIDevice currentDevice] model]);
    NSRange range = [[[UIDevice currentDevice] model] rangeOfString:@"iPad"];
    return !(range.location==NSNotFound);
}
j_freyre
  • 4,623
  • 2
  • 30
  • 47