Friday, April 25, 2014

Iphone version detection

#define IS_DEVICE_RUNNING_IOS_7_AND_ABOVE() ([[[UIDevice currentDevice] systemVersion] compare:@"7.0" options:NSNumericSearch] != NSOrderedAscending)
#define iPhone4Or5oriPad ([[UIScreen mainScreen] bounds].size.height == 568 ? 5 : ([[UIScreen mainScreen] bounds].size.height == 480 ? 4 : 999))
Now in programming you can say...
if (IS_DEVICE_RUNNING_IOS_7_AND_ABOVE()) {
    NSLog("This is iOS 7");
} else {
    NSLog("This is iOS 6 or below");
}


if (iPhone4Or5oriPad==4) {
    NSLog("This is 3.5 inch iPhone - iPhone 4s or below");
} else if (iPhone4Or5oriPad==5) {
    NSLog("This is 4 inch iPhone - iPhone 5 & above");
} else {
    NSLog("This is iPad");
}

No comments:

Post a Comment