简体   繁体   English

我应该在哪里放置Appcelerator iOS的图片?

[英]Where do I put image for appcelerator ios?

I'm porting my android app over to ios, using appcelerator titanium. 我正在使用Appcelerator Titan将我的Android应用程序移植到ios。

If i define an image for use in a view or whatever like so 如果我定义用于视图或类似的图像

backgroundImage : "/images/blueButton.png",

What is the file location that i would put blueButton.png? 我要放置blueButton.png的文件位置在哪里?
Is it /resources/iphone , /resources/images , or something else? /resources/iphone/resources/images还是其他?

According to Malcolm Hollingsworth in this answer on the archived Appcelerator forum : 根据Malcolm Hollingsworth在归档的Appcelerator论坛上的以下回答

Device specific images should be placed inside the android folder of android specific images and iphone for iOS images (iPhone, iPod and iPad). 设备特定的图像应放置在android特定图像的android文件夹内,iOS图像(iPhone,iPod和iPad)的iphone应放置在其中。

If you are creating an app that support both main platforms and some image are the same no matter the device (think photos) then you can and should create a folder outside the device folders. 如果要创建一个同时支持两个主要平台的应用程序,并且无论设备(例如照片)都支持某些图像,则可以并且应该在设备文件夹之外创建一个文件夹。

With this example: 在此示例中:

Now in a cross platform app supporting all image densities (or at least the main ones - your folders would look like this with the images inside; 现在,在支持所有图像密度(或至少主要密度)的跨平台应用程序中,您的文件夹看起来像这样,其中包含图像;

 /resources/ /resources/android/ /resources/android/images/res-ldpi/test1.png /resources/android/images/res-mdpi/test1.png /resources/android/images/res-hdpi/test1.png /resources/android/images/res-xhdpi/test1.png /resources/iphone/ /resources/iphone/images/test1.png /resources/iphone/images/test1@2x.png 

With these two being 有了这两个

 /resources/iphone/images/test1.png = non-retina /resources/iphone/images/test1@2x.png = retina 

... ...

Then your code would be; 然后您的代码将是;

 var myImageView = Ti.UI.createImageView({ height: Ti.UI.SIZE, image : '/images/test1.png', width: Ti.UI.SIZE }); 

Hat tip to Malcolm Hollingsworth. 给马尔科姆·霍林斯沃思的小费。

For iOS Places images in "/resources/images" path and that should work fine. 对于iOS,将图片放在“ / resources / images”路径中,应该可以正常工作。 for iOS non-retina display image name in resource folder should be normal (in our example below it will be myImage.png), for retina display image name in resource folder should be myImage@2x.png with double size than non-retina image. 对于iOS,资源文件夹中的非视网膜显示图像名称应该是正常的(在下面的示例中为myImage.png),对于资源文件夹中的视网膜显示图像名称应该是myImage@2x.png,其大小比非视网膜图像大一倍。

For Android Place images in device specific folder in "resources/android/images/" path and that should work fine. 对于Android设备,将图像放在“ resources / android / images /”路径中的设备专用文件夹中,应该可以正常工作。

var myImage = Titanium.UI.createImageView({
height : Titanium.UI.SIZE,
width : Titanium.UI.SIZE,
image : "/images/myImage.png"
});

this code will work fine for both android and iOS. 此代码对于android和iOS都可以正常工作。

Note : in iOS you can directly place images in iPhone folder and use image : "myImage.png" as parameter in createImageView, but it won't work in android. 注意:在iOS中,您可以直接将图像放置在iPhone文件夹中,并在createImageView中使用图像:“ myImage.png”作为参数,但是在android中将无法使用。 so it's better to use above folder structure where same images are used in iOS and android both. 因此最好使用上面的文件夹结构,在iOS和Android中使用相同的图像。 you can places images that are device specific directly in iPhone folder as they will never be used in android devices. 您可以将特定于设备的图像直接放置在iPhone文件夹中,因为它们永远不会在android设备中使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM