Swift 2
class UIScrollViewSuperTaps: UIScrollView {
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
if self.dragging {
super.touchesBegan(touches, withEvent: event)
} else {
self.superview?.touchesBegan(touches, withEvent: event)
}
}
override func touchesCancelled(touches: Set<UITouch>?, withEvent event: UIEvent?) {
if self.dragging {
super.touchesCancelled(touches, withEvent: event)
} else {
self.superview?.touchesCancelled(touches, withEvent: event)
}
}
override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) {
if self.dragging {
super.touchesEnded(touches, withEvent: event)
} else {
self.superview?.touchesEnded(touches, withEvent: event)
}
}
override func touchesMoved(touches: Set<UITouch>, withEvent event: UIEvent?) {
if self.dragging {
super.touchesMoved(touches, withEvent: event)
} else {
self.superview?.touchesMoved(touches, withEvent: event)
}
}
}
Swift 3
class UIScrollViewSuperTaps: UIScrollView {
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
if self.isDragging {
super.touchesBegan(touches, with: event)
} else {
self.superview?.touchesBegan(touches, with: event)
}
}
override func touchesCancelled(_ touches: Set<UITouch>, with event: UIEvent?) {
if self.isDragging {
super.touchesCancelled(touches, with: event)
} else {
self.superview?.touchesCancelled(touches, with: event)
}
}
override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
if self.isDragging {
super.touchesEnded(touches, with: event)
} else {
self.superview?.touchesEnded(touches, with: event)
}
}
override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
if self.isDragging {
super.touchesMoved(touches, with: event)
} else {
self.superview?.touchesMoved(touches, with: event)
}
}
}
Don't forget to assign class UIScrollViewSuperTaps
to your scroll view in storyboard or in code depending on how you created it.