Currently, I need to convert iOS application from iOS 4.0 (3.5 inch display) to iOS 6.0 (4 inch display).
Please suggest me the easiest way for how to make an iOS older verion (5.0 and older) application compatible with ios6 and iPhone5.
Help me for how to set frames of UI objects of 3.5 inch XIB's for 4 inch XIB.
If any one has a good tutorial or article related to this topic then please provide me link.
You should use following code for detecting ios6 and iphone 5 and after distinguishing perform necessary changes as required.
to conform to version specified in system defines
//#define __IPHONE_2_0 20000
//#define __IPHONE_2_1 20100
//#define __IPHONE_2_2 20200
//#define __IPHONE_3_0 30000
//#define __IPHONE_3_1 30100
//#define __IPHONE_3_2 30200
//#define __IPHONE_4_0 40000
//#define __IPHONE_6_0 60000 You can write function like this ( you should probably store this version somewhere rather than calculate it each time ):
+ (NSInteger) getSystemVersionAsAnInteger{
int index = 0;
NSInteger version = 0;
NSArray* digits = [[UIDevice currentDevice].systemVersion componentsSeparatedByString:@"."];
NSEnumerator* enumer = [digits objectEnumerator];
NSString* number;
while (number = [enumer nextObject]) {
if (index>2) {
break;
}
NSInteger multipler = powf(100, 2-index);
version += [number intValue]*multipler;
index++;
}
return version;
}
Then you can use this as follows:
if([Toolbox getSystemVersionAsAnInteger] >= __IPHONE_6_0)
{
//blocks
} else
{
//oldstyle
}
After determining version of OS use following steps for transition.
Example:
CGRect screenBounds = [[UIScreen mainScreen] bounds];
if (screenBounds.size.height == 568) {
// code for 4-inch screen
}else{
// code for 3.5-inch screen
}
Thanks.