我找到了一種將UIImagePickerControllerSourceTypePhotoLibrary
的圖像存儲在NSArray
中的方法,但我找不到解決方案來查看NSArray
中的UIImageView
中的圖像。這裏是鏈接到店面形象:如何查看數組中存儲的圖像?
Can the selected images from library be stored in an array?
我找到了一種將UIImagePickerControllerSourceTypePhotoLibrary
的圖像存儲在NSArray
中的方法,但我找不到解決方案來查看NSArray
中的UIImageView
中的圖像。這裏是鏈接到店面形象:如何查看數組中存儲的圖像?
Can the selected images from library be stored in an array?
你只需要通過數組迭代...
for(UIImage *img in self.imageArray){
self.image = img;
}
或者ImageView的:
for(UIImageView *imgView in self.imageArray){
self.imageView = imgView;
}
感謝它工作,你忘了添加.image ---- self.imageview.image = imgview –
我很高興它幫助。接受這個答案,所以其他有類似問題的人可以看到它。最好的隊友。 – Stefan
可以說你存儲的圖像排列:
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];
}
}
你嘗試過什麼從陣列獲取的圖像? –