[英]How to view stored images in an array?
I found a way to store images of UIImagePickerControllerSourceTypePhotoLibrary
in an NSArray
but I can not find a solution to view images in an UIImageView
from the NSArray
. 我找到了一种方法来存储的图像
UIImagePickerControllerSourceTypePhotoLibrary
在NSArray
,但我不能找到一个解决方案在浏览图片UIImageView
从NSArray
。 Here is the link to store image: 这是存储图像的链接:
Can the selected images from library be stored in an array? 从库中选择的图像可以存储在数组中吗?
You just need to iterate through that array... 您只需要遍历该数组即可。
for(UIImage *img in self.imageArray){
self.image = img;
}
Or imageView: 或imageView:
for(UIImageView *imgView in self.imageArray){
self.imageView = imgView;
}
Lets say you stored images in array : 假设您将图像存储在array中:
NSArray *imageArray = @[image1, image2, image3]; //imageX are arbitrary name for images.
To view these images one by one, you need to load them and show in UIImageView: 要一一查看这些图像,您需要加载它们并在UIImageView中显示:
//lets assume you have multiple buttons and all targeted to this method.
-(IBAction)buttonClicked:(UIButton *)sender{
NSInteger index = sender.tag;
//here index is the integer to load the image.
if(index < imageArray.count){
self.imageView setImage: imageArray[index];
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.