Alex Rivera | Logout

Display local image in UIImageView

Asked 2011-07-13T05:51:15.147
22

How do I display an image in the UIImageView component from the hard drive?

I have a local folder called "images" and would like to access it via a relative path, since I want to package the images with the app.

Edit
Report

1 Answer

0

What do you mean by images in hard drive.Are you saying that you have kept your images in your bundle in iphone app.If so then you can make array of those images like this....

NSMutableArray *imageArray;
imageArray=[[NSMutableArray alloc]initWithObjects:@"001.jpg",@"002.jpg",@"003.jpg",@"004.jpg",nil];

And then can access your images by this array;

Or if you simply want to show a single image from the bundle you can do this way

UIImageView *creditCardImageView=[[UIImageView alloc]initWithFrame:CGRectMake(10, 16, 302, 77)];
    creditCardImageView.image=[UIImage imageWithContentsOfFile:[[NSBundle mainBundle]pathForResource:@"CreditCard_2RowTable" ofType:@"png"]];
    [self.view addSubview:creditCardImageView];

This will help you.

answered 2011-07-13T05:59:42.177

Your Answer