我正在创建UIImagePickerController来拍摄这样的照片。但是,在此声明中,

    cameraUI.mediaTypes  = [kUTTypeImage]

它显示如下错误:



我该怎么办?我现在正在使用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导入为kUTTypeImage中定义为MobileCoreServiceslet kUTTypeImage: CFString!

因此,添加框架MobileCoreServices并将import MobileCoreServices写入.swift文件中。

转到BuildPhase-> Link Libraries-> +-> MobileCoreServices.framework

并在import MobileCoreServices文件中添加.swift

编辑:将其替换为kUTTypeImage是可选的,因此将其展开

cameraUI.mediaTypes  = [kUTTypeImage!]

关于ios - UIImagePickerController和致命错误: array element cannot be bridged to Objective-C,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/24981695/

10-09 12:51