david
david

Reputation: 3360

How to display image correctly from link ? ios

I am using this code to display the images on my ios app :

NSData *receivedData = [NSData dataWithContentsOfURL:[NSURL URLWithString:url]];
 self.image=nil;
 UIImage *img = [[UIImage alloc] initWithData:receivedData ];
 self.image = img;

this code work perfect for many images , but it can't display this image : https://docs.google.com/uc?authuser=0&id=0Bw8vnOWKrLfgUmc3aHBkczkwbjQ&export=download

also my android app display it correctly !

what's the problem ?

EDIT : I would mention that i can't open the image on my mac preview , it shows this message : It may be damaged or use a file format that Preview doesn’t recognize. but I can open it with chrome.

Upvotes: 0

Views: 258

Answers (2)

Pr0Ger
Pr0Ger

Reputation: 538

Your image isn't valid png file. Actually it's WebP image. It's supported by Google Chrome, but OS X or iOS doesn't have native support for this format, so that's why your code doesn't work.

Upvotes: 1

Misha
Misha

Reputation: 5380

From what I see the link is not an image, it redirects to another link which is also not an image.

Upvotes: 0

Related Questions