作者热门文章
- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
嗨我有这个识别器,设置了 2 个触摸,但它只返回一个,而不是两个 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:(UITapGestureRecognizer *)recognizer {
CGPoint location = [recognizer locationInView:self.view];
NSLog(@"x %f y %f",location.x, location.y);
}
据我了解,我用这两种方法循环触摸次数,但我还没有弄清楚如何:
-(CGPoint)locationOfTouch:(NSUInteger)touchIndex inView:(UIView *)view {
}
-(NSUInteger)numberOfTouches {
}
非常感谢!
最佳答案
在 numTap2 中,使用:
CGPoint location = [recognizer locationOfTouch:touchIndex inView:self.view];
其中 touchIndex
为 0 或 1。
关于objective-c - locationOfTouch 和 numberOfTouches,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5979333/
嗨我有这个识别器,设置了 2 个触摸,但它只返回一个,而不是两个 CGPoint -(void)gestureLoad { UIGestureRecognizer *recognizer; recog
我是一名优秀的程序员,十分优秀!