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!]

相关文章

UITabBarController 是 iOS 中用于管理和显示选项卡界面的一...
UITableView的重用机制避免了频繁创建和销毁单元格的开销,使...
Objective-C中,类的实例变量(instance variables)和属性(...
从内存管理的角度来看,block可以作为方法的传入参数是因为b...
WKWebView 是 iOS 开发中用于显示网页内容的组件,它是在 iO...
OC中常用的多线程编程技术: 1. NSThread NSThread是Objecti...