identifying the device for iPad iOS 4.2
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 mainScre开发者_C百科en] bounds];
self.view.frame = frame;
#else
CGRect frame = [self.view bounds];
#endif
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.
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
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.
精彩评论