[TIMOB-11197] iOS: Request to support iPhone5 specific images (-568h suffix) in the resources other than the splash screen
GitHub Issue | n/a |
---|---|
Type | New Feature |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2012-12-13T00:48:40.000+0000 |
Affected Version/s | Release 2.1.3 |
Fix Version/s | Release 3.0.1, Release 3.1.0, 2012 Sprint 25, 2012 Sprint 25 API |
Components | iOS |
Labels | api, iphoneAssets, qe-review |
Reporter | Anirudh Nagesh |
Assignee | Vishal Duggal |
Created | 2012-09-27T17:53:01.000+0000 |
Updated | 2013-02-25T18:24:26.000+0000 |
Description
As of now, with 2.1.3RC, only default splash screen with -568h suffix are identified as iPhon5 specific by Titanium build process.
It would be useful to have Titanium identify other images ( placed in resources ) with -568h suffix as iphone 5 specific , the way @2X images are included for retina devices.
Currently the workaround is to use if/else logic and include iphone5 specific assets like below.
var iPhone5 = (Ti.Platform.displayCaps.platformHeight===568);
var img = Ti.UI.createImageView();
img.image = (iPhone5) ? '/img/splash-blank-568h.png' : '/img/splash-blank.png';
Attachments
File | Date | Size |
---|---|---|
timob11197.zip | 2012-12-07T18:33:03.000+0000 | 2171506 |
I would recommend that we follow the standard for determining device-specific assets... even though Apple didn't implement it for "iphone5": From https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/LoadingResources/Introduction/Introduction.html#//apple_ref/doc/uid/10000051i-CH1-SW2 :
I have a requirement to add to this feature... We will need a tiapp.xml property to control this feature. I support the feature being either on OR off by default.
@Shannon What is the use case to control this feature through a tiapp.xml property?
The use case would be that I already implemented some custom code to handle this with 2.1.3+, and don't want this new feature.
Well your custom code will not break. The iphone5 specific identifier we are planning to support is -568h@2x (to match the default image identifier). The solution shall be thus. Say you specify an image resource as test1.jpg. Here are the filenames we will test On iPhone idiom if (retina) { if(iphone5) check test1-568h@2x.jpg check test1@2x~iphone.jpg check test1@2x.jpg } check test1~iphone.jpg check test1.jpg On iPad idiom if (retina) { check test1@2x~ipad.jpg check test1@2x.jpg } check test1~ipad.jpg check test1.jpg So if you specify a resource explicitly as test1-568h@2x.jpg (which is what I think you are doing to get the correct scale factor) the check loop will be if (retina) { if(iphone5) check test1-568h@2x-568h@2x.jpg (fail) check test1-568h@2x@2x~iphone.jpg (fail) check test1-568h@2x@2x.jpg (fail) } check test1-568h@2x~iphone.jpg (fail) check test1-568h@2x.jpg (pass)
Test Project
Pull pending https://github.com/appcelerator/titanium_mobile/pull/3555
Ok, I agree with that part. Let me propose an edge case that I don't personally care about, but others might: What if I'm refactoring an app to support the iPhone 5, but haven't finished yet. My app doesn't yet include a Default-568h@2x.png file, but I have some myImage-568h@2x.png assets. Does if(iphone5) evaulate as true under this scenario, or will it always be false if you don't have a Default-568h@2x.png file?
Should evaluate to false because if you do not have the default image the app does not run in full screen so the iPhone5 test will fail
will need backport once 3.0.0 becomes GA
Backport PR to 3_0_X https://github.com/appcelerator/titanium_mobile/pull/3641
Images with (-568h) suffix are getting displayed on iphone5. Verified on: Iphone5 SDK version: 3.0.2.v20130126230207 CLI version : 3.0.24 OS : MAC OSX 10.7.5 XCode : 4.5.1
Verified fix with: Titanium Studio, build: 3.0.2.201301281948 Titanium SDK, build: 3.0.2.v20130129171611 Xcode 4.6 Devices: iPhone 3GS iOS 4.3 iPhone4S iOS 5.0.1 iPhone5 iOS 6.1
I couldn't get this to work with a backgroundImage on a Window. Did support only get added for ImageViews, or did I do something wrong? Tried with 3.0.2GA. This didn't work:
This does work (isiPhone5 checks for 4" retina height):
Hello Shannon. We went back through our test code as well as used the naming and structure you are using. We definitely have something going on. While simulator was working as expected, it seems like the resources are not always copying over the the app during device builds. We could not reliably reproduce the problem. We did at least see it occur. We will focus on the build process as some things happen asynchronously and that is the current thinking. In addition, iOS tends not to let go of the resources from a previous install of the same app ID. This has clouded the results. I will probably open a new bug and relate it to this "feature" ticket.