3

I added the following code to 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");
}

The userInterfaceIdiom always equal to UIUserInterfaceIdiomPhone when running on iPad 2. My iPad 2 is running on iOS 6.1.3.

I cannot find out what the problem is.

Any help is appreciated!

Thanks in advance!

aobs
  • 1,063
  • 1
  • 11
  • 23

2 Answers2

6

Targeted Devices should be Universal,

enter image description here

Thilina Chamath Hewagama
  • 9,039
  • 3
  • 32
  • 45
  • 2
    Try this for non-universal app. `BOOL isiPad = [[UIDevice currentDevice].model hasPrefix:@"iPad"];` – Hlung Sep 17 '14 at 05:11
0

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");
}
Nishant Tyagi
  • 9,893
  • 3
  • 40
  • 61