5

我刚刚下载了新的 Xcode 7 beta 5,但找不到解决此错误的方法。它一直突出显示“pickker.mediaTypes = [kUTTypeImage]”行,并说“无法将'[CFString]'类型的值分配给'[String]'类型的值”

if (UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.Camera)){
        let picker = UIImagePickerController()
        picker.delegate = self
        picker.sourceType = UIImagePickerControllerSourceType.Camera
        picker.mediaTypes = [kUTTypeImage]
        picker.allowsEditing = true
        self.presentViewController(picker, animated: true, completion: nil)
    }
    else{
        NSLog("No Camera.")
    }
4

1 回答 1

10

尝试将 CFString 转换为 String ,如下所示:

picker.mediaTypes = [kUTTypeImage as String]
于 2015-08-20T12:29:26.280 回答