我有一个UITapGestureRecognizer在我看来,我可以得到它与下面的代码精细触摸的位置。 现在,如果我改变触摸该识别器的数量为2(或更多),但它仍然给了我一个位置。 我怎样才能获得两个触摸的两个位置?
tapGesture.locationInView(self.view)
在迅速请帮助。
我有一个UITapGestureRecognizer在我看来,我可以得到它与下面的代码精细触摸的位置。 现在,如果我改变触摸该识别器的数量为2(或更多),但它仍然给了我一个位置。 我怎样才能获得两个触摸的两个位置?
tapGesture.locationInView(self.view)
在迅速请帮助。
而不是使用locationInView
,使用locationOfTouch
让每个抽头的位置:
let tapLocation1 = tapGesture.locationOfTouch(0, inView: self.view)
let tapLocation2 = tapGesture.locationOfTouch(1, inView: self.view)
尝试在开关multipleTouchEnabled
您的自定义视图属性
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
self.multipleTouchEnabled = YES;
}
return self;
}