Ravikumar
Ravikumar

Reputation: 85

IOS::How to load the images in UIImageview in Objective-c

I need to implement this functionality.Any one can you give the sample code.Suggest me. Thanks in advance enter image description here

Upvotes: 0

Views: 132

Answers (1)

Greencat
Greencat

Reputation: 142

First, make sure that your image is in your xcode project.

Then add it to your code by referencing it as a UIImage:

UIImage *myimg = [UIImage imageNamed:@"AppleUSA1.jpg"]

Then create a UIImageView to

UIImageView *imgview = [[UIImageView alloc]initWithFrame:CGRectMake(10, 10, 300, 400)];//creates the view and positions its frame
[imgview setImage:myimg];//Assigns the image to our view
[imgview setContentMode:UIViewContentModeScaleAspectFit];
[self.view addSubview:imgview];//adds the view to the screen

For more info, see http://www.tutorialspoint.com/ios/ios_ui_elements_imageview.htm

Upvotes: 1

Related Questions