Jac*_*ing 37 delegates uiimagepickercontroller ios swift
在我为OCR翻译应用程序编写的一些快速代码中遇到问题.代码段如下:
@IBAction func btnOCR(sender: AnyObject) {
var languageAlert = UIAlertController(title: "For Your Information...", message: "The OCR feature currently only supports English & French.", preferredStyle: .Alert)
languageAlert.addAction(UIAlertAction(title: "Okay", style: .Default, handler: { action in
var image = UIImagePickerController()
image.sourceType = UIImagePickerControllerSourceType.Camera
image.allowsEditing = false
image.delegate = self
presentViewController(image, animated: true, completion: nil)
}))
self.presentViewController(languageAlert, animated: true, completion: nil)
}
Run Code Online (Sandbox Code Playgroud)
image.delegate = self行返回错误:无法将类型viewcontroller的值赋给uiimagepickerdelegate.
我在类定义中设置了委托,这可以在下面看到......
class ViewController: UIViewController, UITextFieldDelegate, UIPickerViewDelegate, UIPickerViewDataSource, UIImagePickerControllerDelegate { }
Run Code Online (Sandbox Code Playgroud)
所有和任何帮助将不胜感激,提前感谢.
Pav*_*lov 83
您忘记了ViewController类defenition中的UINavigationControllerDelegate.
图像选择器的委托对象.
宣言
unowned(unsafe) var delegate: protocol<UIImagePickerControllerDelegate, UINavigationControllerDelegate>?
Run Code Online (Sandbox Code Playgroud)
小智 18
您必须将UINavigationControllerDelegate添加到类声明中.
class ViewController: UIViewController, UITextFieldDelegate, UIPickerViewDelegate, UIPickerViewDataSource, UIImagePickerControllerDelegate, UINavigationControllerDelegate {
// Some thing here
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
14179 次 |
| 最近记录: |