Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create UIImageView with image from a link?

Tags:

How to create UIImageView with image from a link like this http://img.abc.com/noPhoto4530.gif?

like image 986
asedra_le Avatar asked Aug 25 '10 03:08

asedra_le


People also ask

How do I fetch an image in Swift?

Select New > Project... from Xcode's File menu and choose the Single View App template from the iOS > Application section. Name the project Images and set User Interface to Storyboard. Leave the checkboxes at the bottom unchecked. Tell Xcode where you would like to save the project and click the Create button.

What is the difference between a UIImage and a UIImageView?

UIImage contains the data for an image. UIImageView is a custom view meant to display the UIImage .


1 Answers

NSURL *url = [NSURL URLWithString:@"http://img.abc.com/noPhoto4530.gif"];
NSData *data = [NSData dataWithContentsOfURL:url];
UIImage *image = [UIImage imageWithData:data];
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
like image 178
nszombie Avatar answered Oct 06 '22 20:10

nszombie