What is the difference between UIImage
and UIImageView
? Can someone explain it with an example?
In short:
You create an instance of UIImage
object to hold image's data, like this:
NSString *sourcePath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"/picture.jpg"]; //assuming your image is in your app's bundle
UIImage *img = [[UIImage alloc]initWithContentsOfFile:sourcePath];
You then create an instance of UIImageView
either through IB or code to display your image on the screen, like this:
[imageView1 setImage:img]; //assume you already create an instance of UIImageView named imageView1