Mc.Lover Mc.Lover - 2 months ago 38
Objective-C Question

iPad Pro device detection

I am trying to detect iPad Pro device , trying to guess its height with :

NSLog(@"%f",self.view.frame.size.height);


But it returns
1024
! same as iPad non retina devices . any advice ?

I need to specify some codes exact for iPad Pro with this line of code :

#define iPadPro ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad && [UIScreen mainScreen].bounds.size.height == 2732)


...and the codes must detect iPad Pro even on iOS simulator !

Thanks

EDITED :
Some suggest use LunchScreen , but when I use it this happens (scaled down) :
enter image description here

Answer

Special thanks to @rmaddy

The proper way to detect screens sizes is :

NSLog(@"%f",[UIScreen mainScreen].bounds.size.height);

Now if your application runs in Portrait mode you can simply use this code to detect iPad Pro :

#define iPadPro ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad && [UIScreen mainScreen].bounds.size.height == 1366)

Don't forget the need to use a LaunchScreen or the app won't take advantage of the iPad Pro's larger screen

Comments