eusoj
eusoj

Reputation: 374

Native Script is not showing res:// image

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

Upvotes: 5

Views: 5534

Answers (4)

George Edwards
George Edwards

Reputation: 9229

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.

Upvotes: 1

farrellw
farrellw

Reputation: 1420

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.

Upvotes: 7

calebeaires
calebeaires

Reputation: 2084

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.

Upvotes: 0

Tony
Tony

Reputation: 550

It worked for me.

  1. Uninstall the app from the emulator
  2. Re-run your build / livesync
  3. Done

Upvotes: 2

Related Questions