air开发中的requestedDisplayResolution 扫盲
2013-12-05 14:47
211 查看
app.xml里面requestedDisplayResolution 取值可以为high/standard, 如果为high表示设备跟ios声明它需要使用高清屏(其实就是需要最大分辨率)
这里我猜测了一下ios对这个参数的解释,伪代码如下:
下面是目前的苹果设备在不同的requestedDisplayResolution下的屏幕显示情况
stageWidth*stageHeight
设备 requestedDisplayResolution=high requestedDisplayResolution=standard
iphone4/4s 640*960 320*480
iphone5 640*1136 320*480
ipad1/2/mini 768*1024 768*1024
ipad3/4 1536*2048 768*1024
如果我们是以640*960的尺寸为标准开发的IOS程序,设置requestedDisplayResolution为high, 为了让我们的程序在所有IOS设备上都能正常显示,还需要:
1. 假设我们没有使用starling, , 假设我们的程序所有的UI都放置在某个根节点root下,那么,在iphone 3gs下设置root.scaleX = scaleY = 0.5, 在ipad3/4上设置root.scaleX = root.scaleY = 2, (当然,ipad上会有黑边,假设这个可以忍受,或者可以继续缩放到只有一边黑边)。
2. 假设我们使用了starling, 那么在starling构造函数里,先传入640*960的viewport, 然后在iphone 3GS里额外设置 viewPort = new Rectangle(0, 0, 320, 480), 在ipad 3/4上额外设置 viewPort=new Rectangle(0,0, 1536, 2048).
在ipad3/4上做了2倍的放大, 在方案1里会极大影响air的渲染性能。
那么我们可以采取另外一套方法, 在ipad3/ipad4里设置requestedDisplayResolution=standard, 这样就不需要额外做缩放了, 而ios在Ipad3/4上会自动的放大整个程序为2倍大小。
这样带来的另外一个问题是, 我们想发布一次ipa就能兼容所有的设备, 幸好 adobe air 3.6最新beta版本带来了这个属性, 只需要加入这个参数:
那么在Ipad3, ipad4上将默认使用requestedDisplayResolution =standard
这里我猜测了一下ios对这个参数的解释,伪代码如下:
if ( device.hasHighResolutionDisplay) { //设备是否具备高清屏 if (app.requestedDisplayResolution == "high" ) { app.stageWidth = device.maxResolution.x; app.stageHeight = device.maxResolution.y; device.renderAppScale(1); // 以scale=1的正常尺寸渲染整个APP } else { app.stageWidth = device.maxResolution.x/2; app.stageHeight = device.maxResolution.y/2; device.renderAppScale(2); // 以scale=2的放大尺寸渲染整个APP, 实际上就是4个像素点渲染原APP一个像素点 } } else { app.stageWidth = device.maxResolution.x; app.stageHeight = device.maxResolution.y; device.renderAppScale(1); // 以scale=1的正常尺寸渲染整个APP }
下面是目前的苹果设备在不同的requestedDisplayResolution下的屏幕显示情况
stageWidth*stageHeight
设备 requestedDisplayResolution=high requestedDisplayResolution=standard
iphone4/4s 640*960 320*480
iphone5 640*1136 320*480
ipad1/2/mini 768*1024 768*1024
ipad3/4 1536*2048 768*1024
如果我们是以640*960的尺寸为标准开发的IOS程序,设置requestedDisplayResolution为high, 为了让我们的程序在所有IOS设备上都能正常显示,还需要:
1. 假设我们没有使用starling, , 假设我们的程序所有的UI都放置在某个根节点root下,那么,在iphone 3gs下设置root.scaleX = scaleY = 0.5, 在ipad3/4上设置root.scaleX = root.scaleY = 2, (当然,ipad上会有黑边,假设这个可以忍受,或者可以继续缩放到只有一边黑边)。
2. 假设我们使用了starling, 那么在starling构造函数里,先传入640*960的viewport, 然后在iphone 3GS里额外设置 viewPort = new Rectangle(0, 0, 320, 480), 在ipad 3/4上额外设置 viewPort=new Rectangle(0,0, 1536, 2048).
在ipad3/4上做了2倍的放大, 在方案1里会极大影响air的渲染性能。
那么我们可以采取另外一套方法, 在ipad3/ipad4里设置requestedDisplayResolution=standard, 这样就不需要额外做缩放了, 而ios在Ipad3/4上会自动的放大整个程序为2倍大小。
这样带来的另外一个问题是, 我们想发布一次ipa就能兼容所有的设备, 幸好 adobe air 3.6最新beta版本带来了这个属性, 只需要加入这个参数:
<requestedDisplayResolution excludeDevices="iPad3 iPad4">high</requestedDisplayResolution>
那么在Ipad3, ipad4上将默认使用requestedDisplayResolution =standard
相关文章推荐
- SAP HANA 12. SAP UI5 安装
- Administrator privileges required for ole remote procedure call debugging :this feature will not wor
- Engine中如何把没有Z值的Gemetry转为有Z值的Geomtry:报错"the geometry has no Z values"
- UIButton 按钮控件-IOS开发
- 针对UI给出的背景颜色和透明度#ba9163 35%透明度该如何设置
- windows下使用GUI 把本地代码提交到git远程仓库
- sql server中index的REBUILD和REORGANIZE
- (转)命令行下,用 xcodebuild 生成ipa文件,通过 itms-services 协议安装
- ubuntu64位使用jd-gui的若干问题
- Django model,QuerySet 序列化成json的方法
- poj 1122 FDNY to the Rescue!
- mysql 找不到或无法加载已注册的 .Net Framework Data Provider和Unable to find the requested .Net Framework Data Provider. It may not be installed解决
- UITableView分割线样式与颜色
- According to TLD or attribute directive in tag file, attribute value does not accept any expressions
- 【Android UI】 Shape详解 (GradientDrawable)
- iosUIImage图片反响旋转(内存消耗超大基本应用不到项目中,有大神能解决求告知)
- $.each() 中的 continue、break
- $.each() 中的 continue、break
- query did not return a unique result: 275
- EasyUI的一些封装方法