Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 75885

How can I tell if an image is in my resources on iOS

$
0
0

I have several images in my resources. I would like to display a text label if the image doesn't exist.
How can I tell if the image exists on iOS?
On Android I currently do
'app.AppContext.Resources.GetIdentifier(name, "drawable", app.AppContext.PackageName)' where name is the name of the image I'm looking for.
If it exists then I load the image, otherwise I display a nice text label.

But I don't see how to do that on iOS. Working with Files suggests looking at GetManifestResourceNames, but this is empty (I'm calling this in the iOS side as that is where the resources are stored)

I tired to use some combination of Image and FileImageSource, but that doesn't seem to fail if the file doesn't exist.

Is there another mechanism I can use? It would be awesome if I could do this in shared code, but I don't mind have iOS specific code either.


Viewing all articles
Browse latest Browse all 75885

Trending Articles