Skip to content

Difference in jpg resource syntax on iOS/Android #1788

Closed

Description

@tjvantoll

In order to use a .jpg file that lives in App_Resources on iOS I must use res://my_file.jpg, whereas on Android I need to use res://my_file (no extension). This forces me to needlessly fork my code to use an image with the same name.

You can find a live example in the Groceries repo’s angular branch. See https://github.com/NativeScript/sample-Groceries/blob/5f3c416567ab77b605c90775708a4ae5fcb758e8/app/platform.android.css#L2 and https://github.com/NativeScript/sample-Groceries/blob/5f3c416567ab77b605c90775708a4ae5fcb758e8/app/platform.ios.css#L2.

Thanks.

Activity

  1. enchev commented on Mar 24, 2016

    @enchev
    Contributor

    Hey @tjvantoll,

    Thanks to @tzraikov we've found what's going on. You can find here more info:
    https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIImage_Class/index.html#//apple_ref/doc/uid/TP40006890-CH3-SW10

    Our current Deployment Target for {N} iOS projects is 7.0. In theory we can add some additional code to try to load the same image with extension if imageNamed returns null - do you think we should do this?

    [UPDATE] I've made pull request.

  2. tjvantoll commented on Mar 24, 2016

    @tjvantoll
    ContributorAuthor

    Thanks a lot for tracking this down @enchev & @tzraikov. This is an interesting one. At the end of the day what’s most important to me is that I can use the same syntax for both iOS and Android. So I’m fine using either res://my-image or res://my-image.jpg as long as that loads my-image.jpg on both platforms.

    I think your pull request makes a lot of sense, assuming there’s no performance hit... which, I assume there wouldn’t be because you should never hit that check when you’re dealing with .png files.

  3. added this to the milestone on Mar 24, 2016
  4. self-assigned this
    on Mar 24, 2016
  5. added
    ready for testTSC needs to test this and confirm against live production apps and automated test suites
    on Mar 24, 2016
  6. assigned and unassigned on Mar 24, 2016
  7. added a commit that references this issue on Apr 8, 2016
  8. added and removed
    ready for testTSC needs to test this and confirm against live production apps and automated test suites
    on Apr 8, 2016
  9. removed their assignment
    on May 1, 2017
  10. lock commented on Aug 28, 2019

    @lock

    This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

  11. locked and limited conversation to collaborators on Aug 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions