Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-11197] iOS: Request to support iPhone5 specific images (-568h suffix) in the resources other than the splash screen

GitHub Issuen/a
TypeNew Feature
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2012-12-13T00:48:40.000+0000
Affected Version/sRelease 2.1.3
Fix Version/sRelease 3.0.1, Release 3.1.0, 2012 Sprint 25, 2012 Sprint 25 API
ComponentsiOS
Labelsapi, iphoneAssets, qe-review
ReporterAnirudh Nagesh
AssigneeVishal Duggal
Created2012-09-27T17:53:01.000+0000
Updated2013-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

FileDateSize
timob11197.zip2012-12-07T18:33:03.000+00002171506

Comments

  1. Shannon Hicks 2012-09-30

    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 : . myImage~ipad.png / myImage~ipad@2x.png I propose we add a "iphone5" device designation.
  2. Shannon Hicks 2012-12-07

    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.
  3. Vishal Duggal 2012-12-07

    @Shannon What is the use case to control this feature through a tiapp.xml property?
  4. Shannon Hicks 2012-12-07

    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.
  5. Vishal Duggal 2012-12-07

    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)
  6. Vishal Duggal 2012-12-07

    Test Project
  7. Vishal Duggal 2012-12-07

    Pull pending https://github.com/appcelerator/titanium_mobile/pull/3555
  8. Shannon Hicks 2012-12-07

    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?
  9. Vishal Duggal 2012-12-07

    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
  10. Sabil Rahim 2012-12-13

    will need backport once 3.0.0 becomes GA
  11. Vishal Duggal 2012-12-27

    Backport PR to 3_0_X https://github.com/appcelerator/titanium_mobile/pull/3641
  12. Paras Mishra 2013-01-29

    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
  13. Olga Romero 2013-02-01

    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
  14. Shannon Hicks 2013-02-22

    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:
    win.backgroundImage = 'images/backgrounds/login.png';
    This does work (isiPhone5 checks for 4" retina height):
    win.backgroundImage = isiPhone5 ? 'images/backgrounds/login-568@2x.png':'images/backgrounds/login.png';
  15. Eric Merriman 2013-02-25

    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.

JSON Source