Swift:我如何获得UIImagePickerControllerMediaType的记录值

时间:2016-02-14 01:47:37

标签: ios swift

目前要知道什么是媒体类型我获得“public.image”如果用户选择图像到相机胶卷或拍摄新照片,“public.movi​​e”如果是电影。

我阅读了UIImagePickerControllerMediaType的Apple文档,我看到了:

let UIImagePickerControllerMediaType: String

常量

UIImagePickerControllerMediaType

Specifies the media type selected by the user.

The value for this key is an NSString object containing a type code such as kUTTypeImage or kUTTypeMovie.

这是我的代码:

    let mediaType:String = info[UIImagePickerControllerMediaType] as! String


    if mediaType == "public.image" {
        ....

    } else if mediaType == "public.movie" {
        ....
    }

如何将mediaType与官方文档值(kUTTypeImage或kUTTypeMovie)进行比较?

1 个答案:

答案 0 :(得分:2)

mediaType == String(kUTTypeImage)