【发布时间】:2011-02-03 20:10:02
【问题描述】:
我需要检测两个手指触摸事件。如果我同时用两根手指触摸屏幕,那么一切正常。只需使用这样的代码:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [[touches allObjects] objectAtIndex:0];
CGPoint point1 = [touch locationInView:self];
CGPoint point2 ;
NSLog(@"First: %f %f", point1.x, point1.y) ;
if ([[touches allObjects] count] > 1) {
UITouch *touch2 = [[touches allObjects] objectAtIndex:1];
point2 = [touch2 locationInView:self];
NSLog(@"Second: %f %f", point2.x, point2.y) ;
}
}
但如果我握住一根手指然后用另一根手指触摸屏幕,则此代码不起作用。如何实施?很难吗?
【问题讨论】:
标签: iphone objective-c