userInterfaceIdiom始终指示iPhone

aob*_*obs 3 ios

我将以下代码添加到AppDelegate:

if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
    self.viewController = [[ViewController alloc] initWithNibName:@"ViewController_iPhone" bundle:nil];
    NSLog(@"iPhone found");
} else {
    self.viewController = [[ViewController alloc] initWithNibName:@"ViewController_iPad" bundle:nil];
    NSLog(@"iPad found");
}
Run Code Online (Sandbox Code Playgroud)

在iPad 2上运行时,userInterfaceIdiom始终等于UIUserInterfaceIdiomPhone.我的iPad 2在iOS 6.1.3上运行.

我无法找出问题所在.

任何帮助表示赞赏!

提前致谢!

Thi*_*ama 6

目标设备应该是通用的,

在此输入图像描述

  • 尝试使用非通用应用程序.`BOOL isiPad = [[UIDevice currentDevice] .model hasPrefix:@"iPad"];` (2认同)