-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;
这几个事件可以处理多触点的起始、移动、结束状态,但是有一个问题困惑了我很久。两根手指,分别用point1和point2来记录当前轨迹,如果两个手指同时移动的时候可以在touchesMoved同时获得两个手指的坐标,但是如果一个手指按着不动,另外一个手指动,那么touchesMoved只会有一个手指的坐标,那么我要怎么判断动的是第一个手指还是第二个手指啊,这个问题好困惑啊。 

解决方案 »

  1.   

    1.view里面的multipleTouchEnabled的属性等于YES
    2.-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;
    (NSSet *)touches里面是一个手势的集合,在里面返回的是多点触摸的信息。
      

  2.   

    NSArray *touches = [event.allTouches allObjects];
    CGPoint pointOne = [[touches objectAtIndex:0] locationInView:self];
    CGPoint pointTwo = [[touches objectAtIndex:1] locationInView:self];
    可以说明是两个触点
      

  3.   

    这个我知道,但是现在问题是,如果只有一个手指动,另一个手指不动,那么NSArray *touches = [event.allTouches allObjects];里面只有一个手指,但是我不知道这个手指是哪个手指