[英]How to view stored images in an array?
我找到了一种方法来存储的图像UIImagePickerControllerSourceTypePhotoLibrary
在NSArray
,但我不能找到一个解决方案在浏览图片UIImageView
从NSArray
。 这是存储图像的链接:
您只需要遍历该数组即可。
for(UIImage *img in self.imageArray){
self.image = img;
}
或imageView:
for(UIImageView *imgView in self.imageArray){
self.imageView = imgView;
}
假设您将图像存储在array中:
NSArray *imageArray = @[image1, image2, image3]; //imageX are arbitrary name for images.
要一一查看这些图像,您需要加载它们并在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.