我在 UISplitView 内的 iPad 上有一个 UIControl 子类。在控件中从左向右拖动会调用 UISplitView 的显示主视图功能。下面是我在控件中进行的触摸跟踪。有没有办法防止拖动被识别为 UISplitView 上的手势?
override func beginTrackingWithTouch(touch: UITouch, withEvent event: UIEvent?) -> Bool {
super.beginTrackingWithTouch(touch, withEvent: event)
shouldMoveHandle = isPointInHandle(touch.locationInView(self))
return true
}
override func continueTrackingWithTouch(touch: UITouch, withEvent event: UIEvent?) -> Bool {
super.continueTrackingWithTouch(touch, withEvent: event)
let lastPoint = touch.locationInView(self)
if shouldMoveHandle {
let center = CGPoint(x: bounds.size.width / 2.0, y: bounds.size.height / 2.0)
angle = 360.0 - angleFromPoints(center, p2: lastPoint )
handlePosition = pointFromAngle(angle)
_value = valueFromAngle(angle)
self.setNeedsDisplay()
}
return true
}
override func endTrackingWithTouch(touch: UITouch?, withEvent event: UIEvent?) {
super.endTrackingWithTouch(touch, withEvent: event)
shouldMoveHandle = false
self.sendActionsForControlEvents(UIControlEvents.ValueChanged)
}