How to retrieve image locally from application and display it on UIImageView with Objective-C
I have loaded the image in application's folder that is source bu开发者_如何学Pythont I could not find the code by which I will display that image on UIImageView using button click event. Please help me out for this.
I have used this following code before:
UIImage *img = [UIImage imageNamed:@"xyz.png"]
but I could not set the UIImageView image to img in the method
Then please help me with code to set the UIImageView image to img in the method I call on my button click.
You can get an image added to your project folder/subfolder using
UIImage *img = [UIImage imageNamed:@"xyz.png"]
Then set the UIImageView image to img in the method you call on your button click.
Drag the image into Xcode and then set up an UIImage variable like this:
UIImage *theImage = [UIImage imageNamed:@"theImage.png"];
then implement it into your UIImage view by 'myImageView.image = theImage;
Make sure you have IBOutlet set up to your image view, though. The easiest way is to just drag the image into Xcode and select it under the popup list in Interface Builder.
精彩评论