[英]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.