当前位置:编程学习 > wap >>

iphone多触点应用手指如何追踪?

-(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.view里面的multipleTouchEnabled的属性等于YES
2.-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;
(NSSet *)touches里面是一个手势的集合,在里面返回的是多点触摸的信息。 --------------------编程问答-------------------- NSArray *touches = [event.allTouches allObjects];
CGPoint pointOne = [[touches objectAtIndex:0] locationInView:self];
CGPoint pointTwo = [[touches objectAtIndex:1] locationInView:self];


可以说明是两个触点 --------------------编程问答--------------------
引用 3 楼 Xiaolongyi 的回复:
NSArray *touches = [event.allTouches allObjects];
CGPoint pointOne = [[touches objectAtIndex:0] locationInView:self];
CGPoint pointTwo = [[touches objectAtIndex:1] locationInView:self];……

这个我知道,但是现在问题是,如果只有一个手指动,另一个手指不动,那么NSArray *touches = [event.allTouches allObjects];里面只有一个手指,但是我不知道这个手指是哪个手指
补充:移动开发 ,  iPhone
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,