我将以下代码添加到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");
}
在iPad 2上运行时,userInterfaceIdiom始终等于UIUserInterfaceIdiomPhone。我的iPad 2在iOS 6.1.3上运行。
我无法找出问题所在。
感谢任何帮助!
提前致谢!
答案 0 :(得分:6)
目标设备应通用,
答案 1 :(得分:0)
使用此
#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
if (!IS_IPAD) {
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");
}