Disable sending gestures for UIControl subclass

372 Views Asked by At

I have a UIControl subclass on an iPad inside of a UISplitView. Dragging left to right in the control invokes the show master view functionality of the UISplitView. Below is the touch tracking that I do in the control. Is there a way to prevent the dragging from being recognized as a gesture on 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)
}
0

There are 0 best solutions below