In 8.2 UserInterfaceIdiom() has
#define UI_USER_INTERFACE_IDIOM() ([[UIDevice currentDevice] respondsToSelector:@selector(userInterfaceIdiom)] ? [[UIDevice currentDevice] userInterfaceIdiom] : UIUserInterfaceIdiomPhone)
In 8.3 UserInterfaceIdiom() has
static inline UIUserInterfaceIdiom UI_USER_INTERFACE_IDIOM() { return ([[UIDevice currentDevice] respondsToSelector:@selector(userInterfaceIdiom)] ? [[UIDevice currentDevice] userInterfaceIdiom] : UIUserInterfaceIdiomPhone); }
So #ifdef UI_USER_INTERFACE_IDIOM always false at 8.3
Note that the title says
The UI_USER_INTERFACE_IDIOM () function is provided for use when deploying to iOS version less than 3.2. If the earliest version of iPhone / iOS you will be deploying is 3.2 or more, you can use - [UIDevice userInterfaceIdiom] directly.
We offer you refactoring
+ (BOOL) isiPad { static BOOL isIPad = NO; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ isIPad = [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad; }); return isIPad; }
source share