Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/108.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
检测iphone 6和6+;在模拟器ios中_Ios_Objective C_Iphone_Macros_Device - Fatal编程技术网

检测iphone 6和6+;在模拟器ios中

检测iphone 6和6+;在模拟器ios中,ios,objective-c,iphone,macros,device,Ios,Objective C,Iphone,Macros,Device,我使用的是xcode 6,我为iPhone3.5(iphone4,4s)、4.0(iphone5,5s)、4.7(iphone6)和5.5(iphone6+)创建了不同的xib。 我正在使用此代码调用xib。这将在头文件中定义 #define IS_IPHONE_5 ( fabs( ( double )[ [ UIScreen mainScreen ] bounds ].size.height - ( double )568 ) < DBL_EPSILON ) #define IS_IPH

我使用的是xcode 6,我为iPhone3.5(iphone4,4s)、4.0(iphone5,5s)、4.7(iphone6)和5.5(iphone6+)创建了不同的xib。 我正在使用此代码调用xib。这将在头文件中定义

#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)
但问题是,当我在iphone6和6+上运行这个应用程序时,它总是给出iphone5的结果。不要调用iphone6和6+xib。
请帮助我。我尝试了所有与检测iphone6和6+相关的stackoverflow问题,但没有找到解决方案。

感谢您的回复,但对于iPhone5,它工作得很好,但在iphone6和6+中无法工作。您有iphone6和6+的启动映像吗?现在您将启动映像添加到项目中。通过此链接。。
- (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;
}