在iOS中为本地应用程序内容创建图库 [英] Create a gallery for local app content in iOS

查看:73
本文介绍了在iOS中为本地应用程序内容创建图库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序会拍摄一些视频和图片,并将它们存储在Application Home/Documents文件夹中.我想创建一个画廊,将打开并显示(和播放)这些项目.我调查了MPMediaPickerController,它看起来像数据相册的唯一选择是相册.

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.

看起来我将不得不创建UICollectionView.这是正确的方法吗?还是有另一种类似于MPMediaPickerController的方法,但是将源设置为数据对象数组?

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?

推荐答案

最好的方法是使用自己的实现UICollectionView. MPMediaPickerController主要适用于与媒体相关的内容(尤其是歌曲和视频)

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

由于具有图像和视频,因此只需使用NSFilemanager即可在Documents Directory中获取文件,并将信息传递给UICollectionView数据源,并处理UICollectionView didSelect方法上的触摸操作.

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.

这篇关于在iOS中为本地应用程序内容创建图库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆