开发者

locationOfTouch and numberOfTouches

hi I have this recognizer, set with 2 touch, but it returns only one, not two CGPoint

-(void)gestureLoad {

UIGestureRecognizer *recognizer;

recognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(numTap2:)];
[(UITapGestureRecognizer *)recognizer setNumberOfTouchesRequired:2];
[self.view addGestureRecognizer:recognizer];
self.tapRecognizer = (UITapGestureRecognizer *)recognizer;
recognizer.delegate = self;
[recognizer release];

}

- (void)numTap2:(UITapG开发者_开发问答estureRecognizer *)recognizer {

CGPoint location = [recognizer locationInView:self.view];
NSLog(@"x %f y %f",location.x, location.y);

}

as I understand, I cycle the number of touch with these two methods, but I have not figured out how to:

-(CGPoint)locationOfTouch:(NSUInteger)touchIndex inView:(UIView *)view {

}

-(NSUInteger)numberOfTouches {

}

thanks a lot!


In numTap2, use:

CGPoint location = [recognizer locationOfTouch:touchIndex inView:self.view];

where touchIndex is either 0 or 1.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜