创建iOS通用应用程序,如何检测所有5个决议? [英] Creating iOS Universal App, How To Detect All 5 Resolutions?

查看:129
本文介绍了创建iOS通用应用程序,如何检测所有5个决议?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

标题很好说。我正在创建一个iOS应用程序,并在添加艺术资产的点。我有5个背景为iPhone低分辨率(iPhone 3GS或更低),iPhone视网膜(iPhone 4或更高),iPhone 5,iPad低分辨率和iPad高分辨率。



根据装置处理载入背景的最佳方法是什么?



方法来测试模拟器中的所有5看起来像什么?现在,当然,你只能测试iPhone和iPad。



此外,这是一个游戏,我使用cocos2d,如果这将有所作为。 p>

解决方案

对于cocos2D-iPhone,默认后缀如下:




  • 非视网膜iPhone :image.png

  • Retina iPhone :image-hd.png
  • li>
  • 非视网膜iPad :image-ipad.png

  • Retina iPad :image-ipadhd .png



请注意 wiki 页面:


警告 建议使用@ 2x后缀。 Apple会以特殊方式处理这些图像,这可能会导致您的
cocos2d应用程序出错。


Cocos2D会自动检测您的硬件并将加载适当的图像。您可以更改AppDelegate.m中的默认后缀。



AFAIK,iPhone 5图片没有后缀,因此您可以手动检测和加载您的自定义sprite,设备高度:

  CGRect screenBounds = [[UIScreen mainScreen] bounds]; 
if(screenBounds.size.height == 568){
// iPhone 5的代码
} else {
//所有其​​他iOS设备的代码
}

和其他人说的一样,你可以通过模拟器测试所有设备(硬件 - >设备) / p>

Title pretty well says it. I'm creating an iOS app and am at the point of add art assets. I have 5 backgrounds for iPhone low res(iPhone 3GS or lower ), iPhone retina (iPhone 4 or higher), iPhone 5, iPad low res, and iPad high res.

What's the best way to handle which background gets loaded based on the device?

Also, is there a way to test what all 5 looks like in the simulator? Right now, of course, you can only test iPhone and iPad.

Also, this is a game and I'm using cocos2d if that would make a difference.

解决方案

For cocos2D-iPhone, the default suffixes are as follows:

  • Non-retina iPhone: image.png
  • Retina iPhone: image-hd.png
  • Non-retina iPad: image-ipad.png
  • Retina iPad: image-ipadhd.png

Note from the wiki page:

WARNING: It is NOT recommend to use the "@2x" suffix. Apple treats those images in a special way which might cause bugs in your cocos2d application.

Cocos2D will automatically detect your hardware and will load the appropriate image. You can change the default suffixes in AppDelegate.m.

AFAIK, there is no suffix for iPhone 5 images, so you can manually detect and load your custom sprite by detecting the device height:

CGRect screenBounds = [[UIScreen mainScreen] bounds];
if (screenBounds.size.height == 568) {
    // code for iPhone 5
} else {
    // code for all other iOS devices
}

And as the others said, you can test all devices through the simulator (Hardware -> Device)

这篇关于创建iOS通用应用程序,如何检测所有5个决议?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆