UIControl concerns incorrect behavior on the left side of VC

I have a UIControl (a subclass of UIView), and when I create it and align it to the left in my view controller, "beginTrackingWithTouch" cannot be called when I touch the view. It will only be called up when I release the touch. What is strange is that the pointInside (point: CGPoint ...) method is called immediately when I touch UIControl, and even more strange when I align this UIControl view on the right side of the view controller, -beginTrackingWithTouch is called immediately when touching the view, not when releasing. Also, beginTrackingWithTouch is called the same call to endTrackingWithTouch. After some testing, it works fine until the view becomes 20 px on the left side, then this strange problem arises again.

Is there a reason UIControl continueTrackingWithTouch cannot register if it is placed on the left side of the controller? Is this Apple method preventing left hand scrolling? On the left side there is nothing that blocks UIControl.

//In public class CustomScrollBar : UIControl //This method gets called everytime when UIControl (red area in picture) is touched override public func pointInside(point: CGPoint, withEvent event: UIEvent?) -> Bool { return CGRectContainsPoint(handleHitArea, point) } //Only gets called when UIControl is touched and let go. It will not get called until your finger lifts off the screen. override public func beginTrackingWithTouch(touch: UITouch, withEvent event: UIEvent?) -> Bool { self.scrollerLine.hidden = true if let delegate = self.delegate { delegate.beginTrackingWithTouch() } guard self.isHandleVisible else{ return false } self.lastTouchLocation = touch.locationInView(self) self.isHandleDragged = true self.setNeedsLayout() return true } 

// Image below: The UIControl view is on the left (blue). If I move this to the right, the methods are perfectly logged.

enter image description here

+5
source share
1 answer

The navigation controller has a built-in gesture recognizer in the opposite direction, sets it to false. Make sure it is set to viewDidAppear

 self.navigationController!.interactivePopGestureRecognizer!.enabled = false 
+2
source

All Articles