[英]How to save an array of images in a collection view swift 4
When I open my app, the first screen comes up with an empty collectionView
of images. 当我打开应用程序时,第一个屏幕上出现一个空的
collectionView
图片。 I press an 'add' button and it brings me to another viewController
. 我按下“添加”按钮,它将带我到另一个
viewController
。 This new screen has a collectionView
with images inside of each cell
. 这个新屏幕具有一个
collectionView
,每个cell
内都有图像。 When i press on one of the images and press 'create' button. 当我按其中一张图像并按“创建”按钮时。 You are brought to the first screen again and see the image you have just selected in the first cell of the previously empty
collectionView
. 您将再次进入第一个屏幕,并在以前为空的
collectionView
的第一个单元格中看到刚刚选择的图像。 I want to save that image in the collectionView
, but I can't figure out how. 我想将该图像保存在
collectionView
,但我不知道如何。 I tried using userDefault
but that didn't work. 我尝试使用
userDefault
但是没有用。
Thanks for any help. 谢谢你的帮助。
Follow below steps to save image into NSMutableArray
. 请按照以下步骤将图像保存到
NSMutableArray
。 Using array you can manage your collectionview. 使用数组,您可以管理您的collectionview。
Note : This will add same image multiple times into array once you select. 注意 :选择后,这会将同一图像多次添加到数组中。 Manage your array accordingly your requirement.
根据需要管理阵列。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.