gpt4 book ai didi

ios - 图像选择器委托(delegate)错误 : cannot assign value of type

转载 作者:搜寻专家 更新时间:2023-11-01 06:05:41 26 4
gpt4 key购买 nike

我正在尝试从 Github 实现这个框架: https://github.com/hyperoslo/ImagePicker

然后我在我的 View Controller 中创建了一个 IBAction,如 Description 中所述:

class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource, UINavigationBarDelegate {

@IBAction func addMemory(sender: UIBarButtonItem) {

let imagePickerController = ImagePickerController()
imagePickerController.delegate = self //Error here
present(imagePickerController, animated: true, completion: nil)

}
}

Error: Cannot assign value of type 'MemoriesTable' to type 'ImagePickerDelegate?'

最佳答案

您还应该实现 ImagePickerDelegate,因为委托(delegate)属于 ImagePickerDelegate 类型。更改如下

class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource, UINavigationBarDelegate, ImagePickerDelegate {

确保实现协议(protocol)方法。

编辑 1

您需要实现ImagePickerDelegate的以下方法

public protocol ImagePickerDelegate: class {

func wrapperDidPress(imagePicker: ImagePickerController, images: [UIImage])
func doneButtonDidPress(imagePicker: ImagePickerController, images: [UIImage])
func cancelButtonDidPress(imagePicker: ImagePickerController)
}

关于ios - 图像选择器委托(delegate)错误 : cannot assign value of type,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38369674/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com