在Xcode 6.3中打破的imagePickerController

时间:2015-04-14 07:21:09

标签: ios xcode swift

升级到最新的Xcode 6.3后,imagePickerController不再有效。知道这种方法的最新变化是什么?

func imagePickerController(picker: UIImagePickerController!, didFinishPickingMediaWithInfo info: NSDictionary!) {...} 

Error message:
'imagePickerController:didFinishPickingMediaWithInfo:' provided by method 'imagePickerController(_:didFinishPickingMediaWithInfo:)' conflicts with optional requirement method 'imagePickerController(_:didFinishPickingMediaWithInfo:)' in protocol 'UIImagePickerControllerDelegate'

3 个答案:

答案 0 :(得分:9)

你使用的是错误的功能,请使用此功能!

func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [NSObject : AnyObject]){
//Your Code
}

答案 1 :(得分:1)

我和你有同样的问题,我做了如下,现在就可以了。

func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [NSObject : AnyObject]) {
    let pickedImage: UIImage = (info as NSDictionary).objectForKey(UIImagePickerControllerOriginalImage) as! UIImage
    let smallPicture = scaleImageWith(pickedImage, newSize: CGSizeMake(250, 250))
    var sizeOfImageView:CGRect = itemImageView.frame
    sizeOfImageView.size = smallPicture.size
    itemImageView.frame = sizeOfImageView
    itemImageView.image = smallPicture
    picker.dismissViewControllerAnimated(true, completion: nil)
}

答案 2 :(得分:1)

在Swift 2中使用此方法

func imagePickerController(picker: UIImagePickerController, 
    didFinishPickingMediaWithInfo info: [String : AnyObject])