Josh O'Connor Josh O'Connor - 2 months ago 5x
iOS Question

UIControl touches not behaving correctly on left side of VC

I have a UIControl (subclass of UIView), and when I create it and align it to the left side in my view controller, the "beginTrackingWithTouch" fails to get called when I touch the view. It will only get called when I release the touch. What is weird is that pointInside(point: CGPoint...) method gets called immediately when I touch the UIControl, and what is even weirder is that when I align this UIControl view on the right side of the view controller, it works fine--beginTrackingWithTouch is called immediately when the view is touched, not when released. In addition, beginTrackingWithTouch is called the same time endTrackingWithTouch is called. Through some testing, it works fine until the view is 20 px from the left side, then this strange issue occurs again.

Is there a reason why the UIControl continueTrackingWithTouch fails to register if it is put on the far left side of a view controller? Is this Apple's way of preventing left hand scroll? There is absolutely nothing on the left side which is blocking the 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 {

guard self.isHandleVisible else{
return false

self.lastTouchLocation = touch.locationInView(self)
self.isHandleDragged = true


return true

//Image below: UIControl view is on the left side (light blue). If I move this on the far right side, the methods register fine.

enter image description here


Navigation controller has a built in back gesture recognizer, set it to false. Make sure that it is set in viewDidAppear

self.navigationController!.interactivePopGestureRecognizer!.enabled = false