Create a gallery for local app content in iOS

旧时模样 提交于 2020-01-06 19:33:51

问题


My app takes some videos and pictures and stores them in the Application Home/Documents folder. I want to create a gallery that will open and display (and playback) these items. I looked into MPMediaPickerController and it looks like the only option for data source there is the Photos Album.

It looks like I will have to go with creating UICollectionView. Is this the right way to do this or is there another way similar to MPMediaPickerController but with setting the source to an array of data objects?


回答1:


The best way to do it is use your own implementation UICollectionView. MPMediaPickerController mainly works for media related(especially for songs and videos)

Since you have images and videos just use NSFilemanager to get the files in Documents Directory and pass the information to UICollectionView datasource and handle the touch actions on the UICollectionView didSelect methods.



来源:https://stackoverflow.com/questions/33705008/create-a-gallery-for-local-app-content-in-ios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!