作者:双子-殇 | 来源:互联网 | 2023-05-27 14:46
我正在尝试将UIPanGestureRecognizer子类化,我想我可能会做一些愚蠢的事情.我试图覆盖UIPanGestureRecognizer从UIGestureRecognizer继承的方法时遇到错误.
我有这个代码
class VPGesture: UIPanGestureRecognizer {
override func touchesBegan(touches: NSSet!, withEvent event: UIEvent!) {
super.touchesBegan(touches, withEvent: event)
}
override func touchesMoved(touches: NSSet!, withEvent event: UIEvent!) {
super.touchesMoved(touches, withEvent: event);
}
override func touchesEnded(touches: NSSet!, withEvent event: UIEvent!) {
super.touchesEnded(touches, withEvent: event);
}
override func touchesCancelled(touches: NSSet!, withEvent event: UIEvent!) {
super.touchesCancelled(touches, withEvent: event);
}
}
这产生了这些错误
非常感谢您的帮助.
1> guojiubo..:
当前接受的答案并不完全正确,实际上,如果要子类化UIGestureRecognizer,则应导入UIGestureRecognizerSubclass.h头文件,该文件在https://developer.apple.com/library/ios/documentation/UIKit/Reference中有描述./UIGestureRecognizer_Class/index.html,请参阅子类注释部分.
与在Swift中一样,这可以作为流程完成:
import UIKit.UIGestureRecognizerSubclass
那你就准备好了.