Quantcast
Channel: iOS Dev Diary » UIImage
Viewing all articles
Browse latest Browse all 12

How to display a UIImage from an NSURL

$
0
0

If you’re displaying images from the main iOS bundle, things are fairly straightforward:

self.imageView.image = [UIImage imageNamed:@"Amy.png"];

But if you have an NSURL to your image then it’s not as easy. It took me some digging to find out that you have to convert the URL into NSData first, and then display the data:

NSData *imageData = [NSData dataWithContentsOfURL:destinationURL];
self.imageView.image = [UIImage imageWithData:imageData];

Convoluted – but currently the only way I know how to do it.






Viewing all articles
Browse latest Browse all 12

Trending Articles