【发布时间】:2019-01-21 04:07:50
【问题描述】:
我想要一个协议:
protocol CameraButtonDelegate: class {
func cameraButtonDidPress(_ sender: UIButton)
}
所以,我可以将任何客户端分配给一个按钮,例如:
cameraButton.addTarget(delegate, action: #selector(cameraButtonDidPress), for: .touchUpInside)
但是,它无法编译,因为我必须在 action 中指定特定函数,例如:
cameraButton.addTarget(delegate, action: #selector(AAPLViewController.cameraButtonDidPress), for: .touchUpInside)
如果我想让一个按钮定位多个客户端,如何解决这个问题?
【问题讨论】:
标签: ios swift uibutton delegation target-action