簡體   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