这是一个音乐应用程序
用户任务是用手指 1、2 和 3 触摸并按住屏幕,触摸之间的时间很短。
如果用户随后按照向下的顺序(1、2、3)抬起手指,那么一切都会按预期进行。所以看起来 multitpletouchenable、userinteractionenable 等标志必须是正确的。
这是一份报告(n 是返回的触摸次数,x 和 y 是位置)(我编辑了输出文件以识别手指 1、2、3
2012-06-27 07:22:36.589 Bowing[757:907] finger 1 Began n=0,x=190, y=860
2012-06-27 07:22:37.207 Bowing[757:907] finger 2 Began n=0,x=346, y=704
2012-06-27 07:22:37.875 Bowing[757:907] finger 3 Began n=0,x=580, y=708
2012-06-27 07:22:38.587 Bowing[757:907] finger 1 Ended n=0,x=191, y=854
2012-06-27 07:22:39.252 Bowing[757:907] finger 2 Ended n=0,x=346, y=722
2012-06-27 07:22:40.019 Bowing[757:907] finder 3 Ended n=0,x=585, y=712
生活很好
如果用户以相反的顺序 (3,2,1) 抬起手指,则在手指 1 抬起之前不会发送消息;然后发送所有三个手指的消息
2012-06-27 07:22:36.589 Bowing[757:907] finger 1 Began n=0,x=190, y=860
2012-06-27 07:22:37.207 Bowing[757:907] finger 2 Began n=0,x=346, y=704
2012-06-27 07:22:37.875 Bowing[757:907] finger 3 Began n=0,x=580, y=708
2012-06-27 07:22:38.587 Bowing[757:907] finger 1 Ended n=0,x=191, y=854
2012-06-27 07:22:39.252 Bowing[757:907] finger 2 Ended n=0,x=346, y=722
2012-06-27 07:22:40.019 Bowing[757:907] finger 3 Ended n=0,x=585, y=712
生活没有那么美好。为了反映屏幕上发生的情况,消息应该按手指 3、手指 2 和手指 1 的顺序到达
这是响应者;无论发送给 super 的消息是否存在,都一样工作
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
// [super touchesBegan:touches withEvent:event];
NSEnumerator *enumerator = [touches objectEnumerator];
UITouch *aTouch;
int counter=0;
while ((aTouch = [enumerator nextObject])) {
/* code that acts on the set’s values */
CGPoint where=[aTouch locationInView:nil];
NSLog(@"Began n=%i,x=%3.0f, y=%3.0f",counter,where.x,where.y);
counter++;
}
}
// Sent to the receiver when a system event (such as a low-memory warning) cancels a touch event.
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event{
// [super touchesCancelled:touches withEvent:event];
NSEnumerator *enumerator = [touches objectEnumerator];
UITouch *aTouch;
int counter=0;
while ((aTouch = [enumerator nextObject])) {
/* code that acts on the set’s values */
CGPoint where=[aTouch locationInView:nil];
NSLog(@"Cancelled n=%i,x=%3.0f, y=%3.0f",counter,where.x,where.y);
counter++;
}
}
// 当一根或多根手指从视图或窗口中抬起时通知接收器。
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
// [super touchesEnded:touches withEvent:event];
NSEnumerator *enumerator = [touches objectEnumerator];
UITouch *aTouch;
int counter=0;
while ((aTouch = [enumerator nextObject])) {
/* code that acts on the set’s values */
CGPoint where=[aTouch locationInView:nil];
NSLog(@"Ended n=%i,x=%3.0f, y=%3.0f",counter,where.x,where.y);
counter++;
}
}