我正致力于在我的应用中检测字母手势。因此,当用户在屏幕中绘制C时,会发生特殊操作,等等。我正在使用识别器类,它具有关于每个字母触点的预定义数据,并且检测正常。我想在我的所有屏幕中使用此功能,所以我将以下方法添加到appDelegate类并仅检测窗口中的触摸,这里发生的是其他视图,如tableview,屏幕内的scrollview阻止触摸事件被发送到窗口 - 如果这完全发生,然后我的代码就像一个魅力。任何帮助表示赞赏。
- (void)processGestureData
{
NSString *gestureName = [recognizer findBestMatchCenter:¢er angle:&angle score:&score];
NSLog(@"gesture Name: %@",gestureName);
if ([gestureName isEqualToString:@"N"] || [gestureName isEqualToString:@"n"])
{//handle N gesture
}
if ([gestureName isEqualToString:@"C"])
{//handle C gesture
}
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[recognizer resetTouches];
[recognizer addTouches:touches fromView:self.window];
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
[recognizer addTouches:touches fromView:self.window];
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
[recognizer addTouches:touches fromView:self.window];
[self processGestureData];
}