我收到错误消息 - 使用未声明的标识符'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];
}
它出了什么问题?
答案 0 :(得分:260)
您必须将框架MobileCoreServices添加到项目中,然后导入它:
目标C:
#import <MobileCoreServices/MobileCoreServices.h>
这将使问题消失。
Swift 4:
import MobileCoreServices
答案 1 :(得分:36)
swift
import MobileCoreServices
目标c
#import <MobileCoreServices/MobileCoreServices.h>
答案 2 :(得分:20)
我是iOS开发和xcode的新手,花了一些时间试图找出导入无效的原因。在与我的团队中经验丰富的成员解决问题后,我发现不仅必须包括
#import <MobileCoreServices/MobileCoreServices.h>
但您还必须将二进制文件链接到MobileCoreServices框架的库到项目的构建阶段。
希望这有帮助!我确实需要这些信息。
答案 3 :(得分:2)
Swift 4 回答,带摄像机代码和imagePicker委托:
import MobileCoreServices
打开摄像机
@IBAction func openVideoCamera(_ sender: Any) {
if UIImagePickerController.isSourceTypeAvailable(.camera) {
let imagePicker = UIImagePickerController()
imagePicker.delegate = self
imagePicker.sourceType = .camera
imagePicker.mediaTypes = [kUTTypeMovie as String]
imagePicker.videoMaximumDuration = 10 // or whatever you want
imagePicker.videoQuality = .typeMedium
imagePicker.allowsEditing = false
present(imagePicker, animated: true, completion: nil)
}
ImagePicker委托:
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
let mediaType = info[UIImagePickerControllerMediaType] as AnyObject
if mediaType as! String == kUTTypeMovie as String {
let videoURL = info[UIImagePickerControllerMediaURL] as? URL
print("VIDEO URL: \(videoURL!)")
}
dismiss(animated: true, completion: nil)
}
答案 4 :(得分:0)
@SetUp(skipped = false)
def setUp() {
// execute test suite here
}
答案 5 :(得分:0)
import MobileCoreServices
迅速
@import MobileCoreServices;
用于目标c