繁体   English   中英

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

[英]How to view stored images in an array?

我找到了一种方法来存储的图像UIImagePickerControllerSourceTypePhotoLibraryNSArray ,但我不能找到一个解决方案在浏览图片UIImageViewNSArray 这是存储图像的链接:

从库中选择的图像可以存储在数组中吗?

您只需要遍历该数组即可。

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.

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