Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

Dynamically display image in IOS xamarin - nitWithContentsOfFile:' method returned nil

$
0
0

I have a portable xamarin application with some "specific overrides" for android and ios.

I have a content page with image that need to be downloaded from server. Since the image is not "public" on the server I cannot use a simple url to add the image to the Image control. So my code is downloading the image, save it locally and then pass the image url to the Image control: string filePath = GetThumbnailPath();

    Image img = new Image
    {
        HorizontalOptions = LayoutOptions.CenterAndExpand,
        WidthRequest = 150,
        HeightRequest = 150,
        Source =  FileImageSource.FromFile(filePath),
        Margin = new Thickness(0, 10, 0, 10)
    };
    layout.Children.Add(img);

on android everything works great. on IOS (the image is saved to:

string directory = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
string filePath = Path.Combine(directory, "thumbnail.jpg");
but when the page is loaded the application crash with: System.Exception: Could not initialize an instance of the type 'UIKit.UIImage': the native 'initWithContentsOfFile:' method returned nil.

I cannot change the image to be a bundled resource (its dynamic) and cannot make the server call public (its an handler require header parameters or cookies)

Thanks Dror S


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>