//// UIDevice+Resolutions.h// //// Created by HelenSong on 12-9-25.// copyright (c) 2012年 . All rights reserved.//#import <UIKit/UIKit.h>enum { UIDevice_iPhonestandardRes = 1,// iPhone 1,3,3GS Standard Resolution (320x960px) UIDevice_iPhoneHiRes = 2,// iPhone 4,4S High Resolution (640x960px) UIDevice_iPhoneTallerHiRes = 3,// iPhone 5 High Resolution (640x1136px) UIDevice_iPadStandardRes = 4,// iPad 1,2 Standard Resolution (1024x768px) UIDevice_iPadHiRes = 5 // iPad 3 High Resolution (2048x1536px)}; typedef NSUInteger UIDeviceResolution;@interface UIDevice (Resolutions) { }+ (UIDeviceResolution) currentResolution;@end
//// UIDevice+Resolutions.m// //// Created by HelenSong on 12-9-25.// copyright (c) 2012年 . All rights reserved.//#import "UIDevice+Resolutions.h"@implementation UIDevice (Resolutions)+ (UIDeviceResolution) currentResolution { if(UI_USER_INTERFACE_IdioM() == UIUserInterfaceIdiomPhone){ if ([[UIScreen mainScreen] respondsToSelector: @selector(scale)]) { CGSize result = [[UIScreen mainScreen] bounds].size; result = CGSizeMake(result.wIDth * [UIScreen mainScreen].scale,result.height * [UIScreen mainScreen].scale); return (result.height == 960 ? UIDevice_iPhoneHiRes : UIDevice_iPhoneTallerHiRes); } else return UIDevice_iPhonestandardRes; } else return (([[UIScreen mainScreen] respondsToSelector: @selector(scale)]) ? UIDevice_iPadHiRes : UIDevice_iPadStandardRes);}@end
方法二:使用宏定义方式判断是否为iphone5
#define iPhone5 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640,1136),[[UIScreen mainScreen] currentMode].size) : NO)
if (!iPhone5) { [[NSBundle mainBundle]loadNibnamed:@"xxxController" owner:self options:nil]; }else { [[NSBundle mainBundle]loadNibnamed:@"xxxController4inch" owner:self options:nil]; }总结
以上是内存溢出为你收集整理的iphone5处理屏幕分辨率全部内容,希望文章能够帮你解决iphone5处理屏幕分辨率所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)