ios – CFString在Swift 2.0和XCODE 7中为kUTTypeImage转换为String

前端之家收集整理的这篇文章主要介绍了ios – CFString在Swift 2.0和XCODE 7中为kUTTypeImage转换为String前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我得到一个错误转换CFString.错误信息是:

Cannot assign a value of type ‘[CFString]’ to a value of type ‘[String].

怎么修?

picker.sourceType = UIImagePickerControllerSourceType.Camera
picker.allowsEditing = false
picker.mediaTypes = [kUTTypeImage] //Error Message : Cannot assign a value of type '[CFString]' to a value of type '[String]'
picker.delegate = self
picker.modalPresentationStyle = .Popover
presentViewController(picker,animated: true,completion: nil)//

解决方法

从头文件
public var mediaTypes: [String]
// default value is an array containing kUTTypeImage.

所以你实际上可以删除那一行.

但是如果你想保留它,你只需要明确表示你想要一个演员:

picker.mediaTypes = [kUTTypeImage as String]
原文链接:https://www.f2er.com/iOS/327837.html

猜你在找的iOS相关文章