Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
- {
- // The device is an iPad running iPhone 3.2 or later.
- }
- else
- {
- // The device is an iPhone or iPod touch.
- }
- if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
- {
- // The device is an iPad
- }
- else
- {
- // The device is an iPhone
- if(([[UIScreen mainScreen] bounds].size.height>520))
- {
- // The device is an iPhone5
- }
- else
- {
- // The device is an iPhone4
- }
- }
- #define isiPhone5 ([[UIScreen mainScreen] bounds].size.height == 568)?TRUE:FALSE
- #define isiPhone (UI_USER_INTERFACE_IDIOM() == 0)?TRUE:FALSE
- if(isiPhone)
- {
- if (isiPhone5)
- {
- //Code for iphone 5
- }
- else
- {
- //iphone 3.5 inch screen
- }
- }
- else
- {
- //[ipad]
- }
- + (NSString *)yesButWhichDeviceIsIt
- {
- BOOL hasRetina = NO;
- if ([UIScreen instancesRespondToSelector:@selector(scale)]) {
- CGFloat scale = [[UIScreen mainScreen] scale];
- if (scale > 1.0) {
- hasRetina = YES;
- }
- }
- if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
- if (hasRetina) {
- return @"iPad retina";
- } else {
- return @"iPad";
- }
- }
- else {
- if (hasRetina) {
- if ([[UIScreen mainScreen] bounds].size.height == 568){
- return @"iPhone5";
- }
- else
- {
- return @"iPhone4s";
- }
- } else {
- return @"iPhone";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement