2015-08-14 155 views
5

我剛剛下載了新的Xcode 7測試版5,但我找不到解決此錯誤的方法。它使突出線「pickker.mediaTypes = [kUTTypeImage]」,並說「不能分配型‘[CFString字符串]’的值類型的值‘[字符串]’」無法將類型'[CFString]'的值賦值爲類型'[String]'的值

if (UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.Camera)){ 
     let picker = UIImagePickerController() 
     picker.delegate = self 
     picker.sourceType = UIImagePickerControllerSourceType.Camera 
     picker.mediaTypes = [kUTTypeImage] 
     picker.allowsEditing = true 
     self.presentViewController(picker, animated: true, completion: nil) 
    } 
    else{ 
     NSLog("No Camera.") 
    } 

回答

10

嘗試鑄造CFString字符串像這樣的字符串:

picker.mediaTypes = [kUTTypeImage as String] 
+0

修復它。謝謝Cloud9999Strife –

+0

@MatthewSmith您的歡迎。如果你對此感到滿意,請接受答案。 – Cloud9999Strife

相關問題