I am using xcode 6 and I created different xib for iphone 3.5(iphone4,4s),4.0(iphone5,5s),4.7(iphone6) and 5.5(iphone6+). I am using this code to call the xib. This define in header file .
#define IS_IPHONE_5 ( fabs( ( double )[ [ UIScreen mainScreen ] bounds ].size.height - ( double )568 ) < DBL_EPSILON )
#define IS_IPHONE_6 (fabs((double)[[UIScreen mainScreen]bounds].size.height - (double)667) < DBL_EPSILON)
#define IS_IPHONE_6_PLUS (fabs((double)[[UIScreen mainScreen]bounds].size.height - (double)736) < DBL_EPSILON)
Now in the viewcontroller file i write this method
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
if (IS_IPHONE_5)
{
UIScreen *mainScreen = [UIScreen mainScreen];
NSLog(@"Screen bounds: %@, Screen resolution: %@, scale: %f, nativeScale: %f",NSStringFromCGRect(mainScreen.bounds), mainScreen.coordinateSpace, mainScreen.scale, mainScreen.nativeScale);
self = [super initWithNibName:@"ViewController_Iphone5" bundle:nil];
}
if (IS_IPHONE_6) {
self = [super initWithNibName:@"ViewController_iphone6" bundle:nil];
}
if (IS_IPHONE_6_PLUS) {
UIScreen *mainScreen = [UIScreen mainScreen];
NSLog(@"Screen bounds: %@, Screen resolution: %@, scale: %f, nativeScale: %f",NSStringFromCGRect(mainScreen.bounds), mainScreen.coordinateSpace, mainScreen.scale, mainScreen.nativeScale);
self = [super initWithNibName:@"ViewController_iphone6+" bundle:nil];
}
else
{
//iphone 3.5 inch
UIScreen *mainScreen = [UIScreen mainScreen];
NSLog(@"Screen bounds: %@, Screen resolution: %@, scale: %f, nativeScale: %f",NSStringFromCGRect(mainScreen.bounds), mainScreen.coordinateSpace, mainScreen.scale, mainScreen.nativeScale);
self = [super initWithNibName:@"ViewController" bundle:nil];
}
return self;
}
but the problem is that when i run this app into iphone 6 & 6+ it always give the result of iphone 5.Do not call the iphone 6 & 6+ xib. please help me..I try all the stackoverflow questions related to detect the iphone6 & 6+ but don't get the solution.