我正在创建UI
ImagePickerController以拍摄这样的照片.但是,在本声明中,
cameraUI.mediaTypes = [kUTTypeImage]
fatal error: array element cannot be bridged to Objective-C
我该怎么办?我现在正在使用Xcode 6 beta版本4.
func presentCamera() { cameraUI = UIImagePickerController() cameraUI.delegate = self cameraUI.sourceType = UIImagePickerControllerSourceType.Camera cameraUI.mediaTypes = [kUTTypeImage] cameraUI.allowsEditing = false self.presentViewController(cameraUI,animated: true,completion: nil) }
编辑 – 我有这样的错误.
解决方法
您需要将MobileCoreServices导入为MobileCoreServices中定义的kUTTypeImage,因为让kUTTypeImage:CFString!.
因此,添加框架MobileCoreServices并在.swift文件中编写导入MobileCoreServices.
转到BuildPhase – >链接库 – > – > MobileCoreServices.framework
并在.swift文件中添加导入MobileCoreServices.
编辑:替换你的行为kUTTypeImage是可选的,所以打开它
cameraUI.mediaTypes = [kUTTypeImage!]