let recognizer: UIGestureRecognizer
for recognizer in self.gestureRecognizers! {
if recognizer is DollarPGestureRecognizer {
recognizer.recognize()
self.clearAll()
}
}
如果识别器是DollarPGestureRecognizer 是什么意思?
而且,recogn()函数在DollarPGesturRecognizer.h中声明为
@interface DollarPGestureRecognizer : UIGestureRecognizer {
DollarP *dollarP;
NSMutableDictionary *currentTouches;
NSMutableArray *currentPoints;
NSMutableArray *points;
int strokeId;
}
- (void)recognize;
@end
如何成功完成识别功能?
答案 0 :(得分:0)
有点不清楚你在问什么但是这里有:
第一个问题答案) recognizer is DollarPGestureRecognizer
如果识别器是DollarPGestureRecognizer类的实例,则返回true
。
第二个问题答案:为了使用DollarPGestureRecognizer,您需要实例化一个实例,然后将其作为手势识别器添加到您希望它处于活动状态的视图中。所以你可以这样做(作为一个粗略的例子):
let dollarRecognizer = DollarPGestureRecognizer(target:self, action:"handleDollarGesture:"
myView.addGestureRecognizer(dollarRecognizer)
然后在该目标类中定义处理程序(在本例中为self)
func handleDollarGesture(recognizer: DollarPGestureRecognizer) {
//Do Something
}
旁注)如果您需要一些帮助来实现自己的自定义UIGestureRecognizer,请查看以下文章: http://www.raywenderlich.com/104744/uigesturerecognizer-tutorial-creating-custom-recognizers