如何查看数组中存储的图像?

How to view stored images in an array?

我找到了一种将 UIImagePickerControllerSourceTypePhotoLibrary 的图像存储在 NSArray 中的方法,但我找不到从 NSArray 中查看 UIImageView 中的图像的解决方案。这是 link 存储图像:

您只需要遍历该数组...

for(UIImage *img in self.imageArray){
self.image = img;
}

或图片视图:

for(UIImageView *imgView in self.imageArray){
self.imageView = imgView;
}

假设您将图像存储在数组中:

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]; 
    }
}