Reputation: 8188
A simple question about images. I want to display 5 images across a width of a view based on information I am processing.
What control do I use to display the images on iphone and can you please provide a code sample how to set the images source property programatically?
Upvotes: 0
Views: 96
Reputation: 15099
UIImageView
Either:
UIImageView *myImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"someImage.png"]];
Or, if the imageView already exists:
myImage.image = [UIImage imageNamed:@"someImage.png"];
This would be easiest to do in Interface Builder (create the Image Controls and layout there, then you can set the image property from code). If you do it in code, you will need to create all 5 of these and then lay them out properly using the frame property of each UIImageView
Documentation: http://developer.apple.com/library/ios/#documentation/uikit/reference/UIImageView_Class/Reference/Reference.html
Upvotes: 1
Reputation: 1714
You would want to use a UIImageView to do that. You could add these either programmatically or with Interface Builder. To change the image in the image view, you would do something like:
[myImageView setImage:[UIImage imageNamed:@"MyImage.png"]];
Upvotes: 0