0

I understood that iOS 4.2 is for iPad as well. The code below is the standard pattern which we all use for identifying the device. how will this change for the 4.2 iPad. Should i change the code to consider the device type rather than version ?

#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 30200
    CGRect frame = [[UIScreen mainScreen] bounds];
    self.view.frame = frame;
#else
    CGRect frame = [self.view bounds];
#endif
KingofBliss
  • 15,055
  • 6
  • 50
  • 72
thndrkiss
  • 4,515
  • 8
  • 57
  • 96

3 Answers3

5

A better way would be [[UIDevice currentDevice] userInterfaceIdiom]

First check that the currentDevice responds to that selector. If not, then it's an iPhone/iPod running iOS 3.1.x or earlier.

If it does respond to that selector, then you can check the result for UIUserInterfaceIdiomPhone or UIUserInterfaceIdiomPad.

Firoze Lafeer
  • 17,133
  • 4
  • 54
  • 48
2

You can try this also:

#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 30200

if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
 {
     // type you code for iPad
 } else {
     // type you code for iPhone
 }

#endif
ZelluX
  • 69,107
  • 19
  • 71
  • 104
iPhoneDv
  • 1,969
  • 1
  • 19
  • 34
0

check device version and the code accordingly

float version = [[[UIDevice currentDevice] systemVersion] floatValue];
    if (version == 4.2)
    {
        CGRect frame = [[UIScreen mainScreen] bounds];
    self.view.frame = frame;

    }
else
    self.view.frame = frame;

Use this code it may help you.

Omer Obaid
  • 416
  • 1
  • 6
  • 24
Ishu
  • 12,797
  • 5
  • 35
  • 51