简体   繁体   中英

Display image in a UIImageView in iPhone

I do not wants use a picker view to pick a image. I have image name abc.JPG which is in iPhone image library, can I programmatically fetch this image and put on UIImageView ?

If the image isn't in your application resource and you don't want to use UIImagePickerController then you can use ALAssetsLibrary to fetch the images on user albums or camera roll.

Take a look here: http://developer.apple.com/library/ios/#documentation/AssetsLibrary/Reference/ALAssetsLibrary_Class/Reference/Reference.html

   UIImageView *myImage = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 460)];

myImage.image = [UIImage imageNamed:@"abc.JPG"];

[self.view addSubview:myImage];

or if you have already uiimageview with name myImage then just write:

myImage.image = [UIImage imageNamed:@"abc.JPG"];

Maybe:

UIImageView *myImageView = [UIImageView alloc] init];
myImageView.image = [UIImage imageNamed:@"abc.JPG"];

Try to follow this tutorial.

Even if you don't want to, I think you have to use UIImagePickerViewController to pick the image, otherwise the image will be picked from Resources in your project.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM