UIImage.LoadFromData() not working on iOS 9?

XamarinUser.1981XamarinUser.1981 UYMember
edited September 2015 in Xamarin.iOS

I had this code working on iOS 8 and when updated to iOS 9 it just stopped working.

static UIImage FromUrl (string uri) { using (var url = new NSUrl (uri)) using (var data = NSData.FromString(uri)) return UIImage.LoadFromData (data); }

Actually, it wasn't that, I had to change NSData.FromUrl(url) to NSData.FromString(uri) because NSData.FromUrl would always return null after iOS 9.
Now UIImage.LoadFromData(data) always returns null and that was working on iOS 8.
Anybody experiencing the same? Any solutions?

Best Answer

Answers

  • Oh, ok. I misunderstood the method. The code that worked was:

    static UIImage FromUrl (string uri) { using (var url = new NSUrl (uri)) using (var data = NSData.FromUrl(url)) return UIImage.LoadFromData (data); }

    I'll check that post you link. In the meantime, no, the url is not https. The thing is, NSData.FromUrl(url) is returning null also. This is the url I'm trying to reach: "http://ia.media-imdb.com/images/M/MV5BMTc4OTkyOTA3OF5BMl5BanBnXkFtZTYwMDIxNjk5.V1_SX150_AL.jpg"

  • XamarinUser.1981XamarinUser.1981 UYMember
    edited September 2015

    @adamkemp you were right. Adding the exception that is suggested on the answer of your link to the info.plist file solves the issue.

    Thanks.

  • JamesGreen.8031JamesGreen.8031 GBMember ✭✭

    Hmm, adding the exception to my plist hasn't fixed it for me. How odd.

Sign In or Register to comment.