首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Iphone >

经过代码判断iphone 4的Retina屏幕分辨率

2012-08-21 
通过代码判断iphone 4的Retina屏幕分辨率iPhone 4 发布以来,开发者面临的一大问题就是软件要适应2种分辨率

通过代码判断iphone 4的Retina屏幕分辨率
iPhone 4 发布以来,开发者面临的一大问题就是软件要适应2种分辨率的屏幕。以下这段代码能判断当前运行的设备是否是 iPhone 4 的 Retina 屏,以便做出图标加载等调整。

//在头上门定义#define isRetina ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 960), [[UIScreen mainScreen] currentMode].size) : NO)//方法中可以实用- (void)loadView{if (isRetina) {        chkUserName = [[UIButton alloc]initWithFrame:CGRectMake(chkUserNameLeft, top,bigWidth,bigHeight)];    }else{        chkUserName = [[UIButton alloc]initWithFrame:CGRectMake(chkUserNameLeft, top,smallWidth,smallHeight)];    }}

热点排行