For me if I have to make changes that are based on different iOS version I use the following class to define functions that can detect which version I'm using. It also only needs a header (.h) file and no implementation (.m) file.
I call this class VersionMacros.
VersionMacros.h :
/*
* System Versioning Preprocessor Macros
* Incluse this header if you want to adjust something based on a system version
*/
#define SYSTEM_VERSION_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define SYSTEM_VERSION_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)
//Use these functions to detect versions. Also import this header file into the file u want to use these funcs.
Then when you want to use a different xib for both versions you can just call this.
if(SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO("7.0"))
{
//The version of the device is iOS7.0 or higher.
//call controller with ios7 xib here
}
else
{
//The version of the device is lower then iOS7.0.
//call controller with ios6 xib here
}
Instead of making and calling different xibs you can also just adjust the frames of the elements that need adjusting. (this is what I prefer)
This would look something like this.
float versionMarginY = 0.0;
if(SYSTEM_VERSION_EQUAL_TO("7.0"))
{
//if system version is exactly 7.0
versionMarginY = 64.0;
}
else if(SYSTEM_VERSION_EQUAL_TO("6.0"))
{
//if system version is exactly 6.0
versionMarginY = 44.0;
}
else
{
//for all other versions we do this
}
//Then adjust a certain view that you can reach in this method
someView.frame = CGRectMake(0, 0 + versionMarginY, someWidthThatHasSomeKindOfValue, someHeightThatHasSomeKindOfValue);
Hope this helps!