userInterfaceIdiom always indicate iPhone

前端 未结 2 1970
失恋的感觉
失恋的感觉 2021-01-20 05:16

I added the following code to AppDelegate:

if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
    self.viewController = [[View         


        
相关标签:
2条回答
  • 2021-01-20 05:51

    Use this

    #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");
    }
    
    0 讨论(0)
  • 2021-01-20 06:04

    Targeted Devices should be Universal,

    enter image description here

    0 讨论(0)
提交回复
热议问题