Swift 1.2 to swift 2:Objective C方法与可选的需求方法冲突

时间:2016-05-04 06:29:23

标签: ios ruby-on-rails ruby swift2 xcode7

我正在尝试根据我在网上找到的教程(https://www.raywenderlich.com/85528/user-accounts-ios-ruby-rails-swift#next_section)开发一款可以访问手机相机的应用。但是我在imagePickerController函数的相机扩展程序不断抛出这个错误:

  

方法“imagePickerController: didFinishPickingMediaWithInfo:”提供的Objective-C方法“imagePickerController(_:didFinishPickingMediaWithInfo:)”与可选的需求方法imagePickerController(_:didFinishPickingMediaWithInfo:)冲突

这是抛出错误的代码

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

受影响的代码块如下所示

// Camera Extension
extension SelfieCollectionViewController : UINavigationControllerDelegate,     UIImagePickerControllerDelegate {
func displayCameraControl() {
var imagePickerController = UIImagePickerController()
imagePickerController.delegate = self
imagePickerController.allowsEditing = true

if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.Camera) {
  imagePickerController.sourceType = UIImagePickerControllerSourceType.Camera

  if UIImagePickerController.isCameraDeviceAvailable(UIImagePickerControllerCameraDevice.Front) {
    imagePickerController.cameraDevice = UIImagePickerControllerCameraDevice.Front
  } else {
    imagePickerController.cameraDevice = UIImagePickerControllerCameraDevice.Rear
  }
} else {
  imagePickerController.sourceType = UIImagePickerControllerSourceType.PhotoLibrary
}

self.presentViewController(imagePickerController, animated: true, completion: nil)
}

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

完整的代码块可以在第111行找到(https://codeshare.io/UurWD)。

1 个答案:

答案 0 :(得分:0)

替换

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

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