我有一个视图控制器:
class CameraViewController: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate {
...
override func viewDidLoad() {
super.viewDidLoad()
self.recordingSpinner.isUserInteractionEnabled = true
let tap = UITapGestureRecognizer(target: self, action: #selector(CameraViewController.handleTap(_:)))
self.recordingSpinner.addGestureRecognizer(tap)
if setupSession(){
setupPreview()
startSession()
}
}
@objc func handleTap(gesture:UIGestureRecognizer) {
startRecording()
guard let animator = animator else {
createAnimation()
return
}
if animator.isRunning {
animator.pauseAnimation()
} else {
animator.startAnimation()
}
}
}
XCode抱怨它在CameraViewController中找不到handleTap但我看到了。我需要改变什么?
答案 0 :(得分:0)
正如@dan建议的那样,执行@objc func handleTap(_ gesture: UIGestureRecognizer)
代替@objc func handleTap(gesture:UIGestureRecognizer)
修复它。
还使用let tap = UITapGestureRecognizer(target: self, action: #selector(handleTap)
也适用