Прежде всего, я должен упомянуть, что мне потребовалось много времени, чтобы понять, почему симулятор ipad «говорил», что это iphone. Для меня оказалось, что мне просто нужно было переключить его на универсальный:

Вот код, который я считаю довольно типичным для этого. Есть и другие, которые, вероятно, тоже работают, но ...
// lifted this from the ios 4 cookbook:
- (BOOL) isiPad{
BOOL result = NO;
NSString *classAsString =
NSStringFromClass([UISplitViewController class]);
if (classAsString == nil ||
[classAsString length] == 0){
return(NO);
}
UIDevice *device = [UIDevice currentDevice];
if ([device respondsToSelector:
@selector(userInterfaceIdiom)] == NO){
return(NO);
}
NSLog(@"Device: %d", [[UIDevice currentDevice] userInterfaceIdiom]);
NSLog(@"Device: %@", [[UIDevice currentDevice] model]);
if ([device userInterfaceIdiom] != UIUserInterfaceIdiomPad){
return(NO);
}
// you can put some screen size tests here too if you'd like
result = YES;
return(result);
}