我在转换CFString时遇到错误。错误信息是:
无法指定类型' [CFString]'的值到#' [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)//
答案 0 :(得分:10)
从头文件中:
public var mediaTypes: [String]
// default value is an array containing kUTTypeImage.
所以你实际上可以删除那一行。
但是如果你想保留它,你只需要明确表示你想要一个演员:
picker.mediaTypes = [kUTTypeImage as String]