0

Currently trying to display an image from my local on my ios app that i've developed using nativescript and not having any luck.

Template:

<GridLayout class="page page-content">
    <StackLayout>
        <Image src="~/img/icon.jpg" stretch="none"></Image>
    </StackLayout>
</GridLayout>

File structure:

enter image description here

Not really sure what im doing wrong, i even tried to play around with the different path of the image.

"~/app/img/icon.jpg" and even put the direct path on there with no luck.

EDIT:

OK so i tried uploading a smaller image and that seemed to go in fine. Any way to optimize an image to work on nativescript?

4
  • If you are using webpack (--bundle), did you try res://icon? Commented Mar 27, 2019 at 21:11
  • hmm i tried using res:// and still no luck. I'm just using the default webpack configuration from the nativescript cli build Commented Mar 27, 2019 at 21:15
  • As an additional feature for Android, NativeScript supports decodeWidth and decodeHeight. These properties will downsample your image so that it will take less memory. The goal is to avoid as much as possible out of memory exceptions caused by images being loaded into memory and at the same time display crispy images. Commented Apr 3, 2019 at 3:31
  • you can also try loadMode="async" useCache Commented Apr 3, 2019 at 3:31

1 Answer 1

3

Create images folder inside your App folder and place path like this:-

~/app/images/logo.png
Sign up to request clarification or add additional context in comments.

1 Comment

This answer works for me! @jeremy: This answer should be accepted.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.