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

时间:2015-12-29 11:50:31

标签: ios objective-c arrays uiimageview uiimagepickercontroller

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

Can the selected images from library be stored in an array?

2 个答案:

答案 0 :(得分:2)

你只需要遍历那个数组......

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

或者imageView:

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

答案 1 :(得分:0)

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

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