gpt4 book ai didi

ios - UIPanGestureRecognizer 没有名为 touchesBegan 的成员

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

我正在尝试继承 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);
}
}

产生这些错误的地方

enter image description here

非常感谢您的帮助。

最佳答案

目前接受的答案不太正确,实际上,如果你想子类化一个 UIGestureRecognizer,你应该导入 UIGestureRecognizerSubclass.h 头文件,它在 https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIGestureRecognizer_Class/index.html 中描述,请参阅子类注释部分。

在 Swift 中,这可以按流程完成:

import UIKit.UIGestureRecognizerSubclass

然后你就可以开始了。

关于ios - UIPanGestureRecognizer 没有名为 touchesBegan 的成员,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27873297/

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