Objective-C method 'imagePickerController: didFinishPickingMediaWithInfo:'

Objective-C method 'imagePickerController: didFinishPickingMediaWithInfo:' provided by the method 'imagePickerController (: didFinishPickingMediaWithInfo :)' conflicts with the optional requirements method 'imagePickerController (: didFinishPickingMediaWithInfo :)' in the 'Ulpeer

The code is below. What's wrong? Using Xcode 6.4 Beta.

func imagePickerController(picker: UIImagePickerController!, didFinishPickingMediaWithInfo info:NSDictionary!) 
+4
source share
4 answers

I had this error after upgrading to version 2.0. Easy to fix, just repeat this method, then autocomplete will focus on changing parameter types. Now it should be:

func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo: [String: Anyobject]) {
+9

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

:

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

    var image: UIImage!

    // fetch the selected image
    if picker.allowsEditing {
      image = info[UIImagePickerControllerEditedImage] as! UIImage
    } else {
      image = info[UIImagePickerControllerOriginalImage] as! UIImage
    }

    // Do something about image by yourself

    // dissmiss the image picker controller window
    self.dismissViewControllerAnimated(true, completion: nil)

  }
+3

It worked for me.

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

    if let pickedImage = info[UIImagePickerControllerOriginalImage] as? UIImage {
        imageView.contentMode = .ScaleAspectFit
        imageView.image = pickedImage
    }

    dismissViewControllerAnimated(true, completion: nil)
}
+1
source

The correct functionality format for your problem:

func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject])
    {
        // Add your functionality here
    }
-1
source

Source: https://habr.com/ru/post/1584583/


All Articles