Questions Questions - 4 years ago 101
Objective-C Question

How to display a picture on UIView programmatically?

I want to ask a question about the UIview on the iPhone applicaiton. I want to display a image one the UIView programmatically, but I don't know how to do it. What should I do to display the image. Thank you very much.

Answer Source

You should use UIImageView. It is a subclass of UIView and you can set the image with an instance on UIImage.

Here is an example to add it to another UIView.

UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"nameofimage.png"]];
[myUIView addSubview:imageView];
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download