How to have a UIScrollView scroll and have a gesture recognizer?
The way that works for me is subclass UIScrollView
and conform to the UIGestureRecognizerDelegate
in that subclass. Then call this method.
class ATScrollView: UIScrollView, UIGestureRecognizerDelegate {
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer,
shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
return true
}
}
Make a subclass of UIScrollView
. Add this method in your new subclass
- (BOOL)gestureRecognizer:(UIPanGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UISwipeGestureRecognizer *)otherGestureRecognizer
{
return YES;
}
Make your scrollView class to your new scrollview subclass.