I have a static UITableView which on cell that looks like this:
我有一个静态的UITableView,它在单元格上看起来像这样:
Getting the Camera and Attach buttons to work was no problem. The user can take a picture or select one from their photo library.
让相机和附加按钮工作是没有问题的。用户可以拍照或从照片库中选择一张照片。
What I want to do 3 things:
我想做什么3件事:
- Take the resulting image from the UIImagePickerController and add a thumbnail below the "Pictures" label.
- 从UIImagePickerController获取生成的图像,并在“图片”标签下添加缩略图。
- Do 1. for multiple images.
- 做1.多个图像。
- Have the option to remove an attached image.
- 可以选择删除附加的图像。
My initial thought is to create a custom UIView that has a UIImageView and a delete button, and create one of these custom views for each image the user attaches and display them in a UICollectionView.
我最初的想法是创建一个具有UIImageView和删除按钮的自定义UIView,并为用户附加的每个图像创建其中一个自定义视图,并在UICollectionView中显示它们。
EDIT: Another option could be to insert a cell below the "Pictures" cell that contains a UIImageView, and enable editing for those cells so they can be removed.
编辑:另一个选项可能是在包含UIImageView的“图片”单元格下面插入一个单元格,并启用这些单元格的编辑,以便可以删除它们。
My question is this: is there a better way of doing this? Are there any online references I should be looking at? I've looked around for a while but haven't been able to find what I'm looking for.
我的问题是:有更好的方法吗?我应该看一下在线参考吗?我环顾了一会儿,但一直找不到我要找的东西。
Thanks!
谢谢!
1 个解决方案
#1
0
I solved this by using a UICollectionView embedded in a UITableViewCell. The cell has a height of 0 to start and only shows when an image is added. Then, images are removed from the collection via UILongPressGesture.
我通过使用嵌入在UITableViewCell中的UICollectionView解决了这个问题。单元格的高度为0,仅在添加图像时显示。然后,通过UILongPressGesture从集合中删除图像。
#1
0
I solved this by using a UICollectionView embedded in a UITableViewCell. The cell has a height of 0 to start and only shows when an image is added. Then, images are removed from the collection via UILongPressGesture.
我通过使用嵌入在UITableViewCell中的UICollectionView解决了这个问题。单元格的高度为0,仅在添加图像时显示。然后,通过UILongPressGesture从集合中删除图像。