【问题标题】:How to view stored images in an array?如何查看存储在数组中的图像?
【发布时间】:2015-12-29 11:50:31
【问题描述】:

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

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

【问题讨论】:

  • 你有没有尝试从数组中获取图像?

标签: ios objective-c arrays uiimageview uiimagepickercontroller


【解决方案1】:

您只需要遍历该数组...

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

或图像视图:

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

【讨论】:

  • 谢谢它的工作,你忘了添加 .image---- self.imageview.image=imgview
  • 我很高兴它有帮助。接受这个答案,以便其他有类似问题的人可以看到它。最好的祝福。
【解决方案2】:

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

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

【讨论】:

    猜你喜欢
    • 2018-06-28
    • 1970-01-01
    • 1970-01-01
    • 2017-10-21
    • 2019-08-08
    • 2014-06-05
    • 2017-11-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多