我有一个类PanAndZoomView
,它继承自UIView
并负责我正在处理的iOS应用中的一个屏幕。项目中还有其他开发人员,应用程序中的许多其他屏幕都不是我的,而且PanAndZoomView不是输入屏幕。
I have multiple touch enabled:
我用以下方法中的print
语句检查
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
print("TouchesBegan, multipleTouchEnabled = \(self.multipleTouchEnabled)")
let newTouches:Set<UITouch> = touches.subtract(self.touchesBeingTracked)
for touch:UITouch in newTouches {
self.initialTouches[touch] = touch.locationInView(self)
self.initialScale = self.contentsView.transform.a
self.initialTranslation = CGVector(dx: self.contentsView.transform.tx, dy: self.contentsView.transform.ty)
}
self.touchesBeingTracked.unionInPlace(touches)
self.touchesBeingTrackedPeakCount = touchesBeingTracked.count
self.segmentationView.containerTouchesBegan(touches, withEvent: event)
}
然而PanAndZoomView只注册我的第一次触摸,即上面的方法只会触发一次,无论我触摸屏幕的手指多少。
我的方法遵循Apple's documentation,并且我在另一个项目中使用相同的PanAndZoomView
类,在这个项目中,它可以毫无问题地看到多个触摸。
为什么忽略第二次触摸?
如何诊断我的问题?
答案 0 :(得分:0)
子视图存在问题。
虽然处理多点触控事件的UIView
(PanAndZoomView
)在故事板中标记为“启用多点触控”,但其两个子视图却没有。将它们标记为启用多点触控可以修复它,以便现在PanAndZoomView可以进行第二次触摸。