我收到错误消息-Use of undeclared identifier 'kUTTypeMovie'

在以下代码中-

-(IBAction)selectVideo:(id)sender {
    UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
    imagePicker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
    imagePicker.mediaTypes = [[NSArray alloc] initWithObjects:(NSString *)kUTTypeMovie, nil];

    imagePicker.delegate = self;
    [self presentModalViewController:imagePicker animated:YES];
}

有什么问题吗?

推荐答案

您需要将框架MobileCoreServices添加到项目中,然后将其导入:

Objective C:

#import <MobileCoreServices/MobileCoreServices.h>

这将使问题消失.

Swift 4:

import MobileCoreServices

Ios相关问答推荐

如何使用UICollectionView Compositionallayout在UIKit中正确渲染远程图像

SwiftUI文本编辑器内部滚动填充,无需文本裁剪

自定义UIControl不适用于UITapGestureRecognizer

BezierPath 中绘制图像形状轮廓的算法(Canny 边缘检测器)

拖动手势导致 sim 崩溃 Swift UI

在 SwiftUI 中以编程方式插入内嵌图像

Swift Combine和iOS版本限制?

垂直分页 UIScrollView 高度不正确

归档时命令 PhaseScriptExecution 失败,退出代码非零

为什么这个 init 被分派到一个内部扩展 init?

如何将 -fobjc-arc-exceptions 标志正确添加到 XCode 中?

从 PHAssets 生成图像时,iOS 应用程序因内存问题而崩溃

SwiftUI 图像与下拉视图切换一起 skip

.onAppear() 函数不适用于 NavigationLink

如何避免任何绑定空错误并更好地获取代码

UIButton在iOS7中没有显示突出显示

通过 segue 传递数据

NSPredicate 用于测试 NULL 和空白字符串

cocoapods中~>的用法是什么

如果我的分发证书过期会怎样?