Reputation: 4595
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
Upvotes: 0
Views: 1327
Reputation: 12787
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.
Upvotes: 0
Reputation: 1969
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
Upvotes: 2
Reputation: 17143
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.
Upvotes: 5