ios – UIImagePickerController和致命错误:数组元素无法桥接到Objective-C

前端之家收集整理的这篇文章主要介绍了ios – UIImagePickerController和致命错误:数组元素无法桥接到Objective-C前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在创建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!]

猜你在找的iOS相关文章