Native Script is not showing res:// image
Asked Answered
P

4

5

I'm following the NativeScript tutorial, but when I'm trying to load the image with res:// is not working with iOS.

<Image src="res://logo" stretch ="none" />

The file is in the App_Resources/iOS/logo.png

UPDATE:

Now works:

1.- Uninstall the app from the device/emulator

2.- Then do a new tns build ios to get a fresh build

Pickaxe answered 7/6, 2016 at 19:59 Comment(0)
G
7

Related steps for the same issue but with Android.

tns platform remove Android
tns platform add Android
tns run Android

Added explanation: The issue here is that your app isn't really running from AppResources. It is actually running from platform/ios and platform/android, both of which are compiled during a fresh build.

So when you add an image under AppResources, great, but unless you rebuild the app is still running on outdated resources found in platform/ios and platform/android.

Removing the platforms and adding the platforms will ensure the folders your app is using mimic App Resources. And your image will be available.

Gery answered 24/3, 2017 at 18:2 Comment(1)
Thanks .. I solved the bug this way only.. what a waste of time though.Letourneau
S
2

It worked for me.

  1. Uninstall the app from the emulator
  2. Re-run your build / livesync
  3. Done
Skald answered 2/8, 2016 at 15:51 Comment(0)
M
1

I expect the issue is with your use of the nativescript cli.

To compile and run a new app, you should run tns prepare ios, then tns build ios then tns launch ios. Alternatively tns run ios completes all these steps. So bear in mind that when adding new platforms, plugins or resources, you should re-run the prepare command.

Mitre answered 7/6, 2016 at 21:37 Comment(2)
I tried with ths prepare ios, but if you don't uninstall the app from the emulator the images still cachedPickaxe
But if you are just adding new images, that shouldn't effect it? Should only be an issue if your image changes but keeps the same file name...Mitre
P
0

Take a look at the tag stretch ="none". It have an space between ch and =. There is an error on Visual Code snippets. Maybe this is the case.

Pandemonium answered 3/8, 2016 at 0:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.