I have a UIScrollView that contains a UISegmentedControl. The idea is that the user can scroll the segmented control back and forth to view options that fall outside the visible area of the device's screen. The user can also tap on a partially visible selection and it'll scroll to the center of the view. This all worked fine until iOS 13. Now the scroll view won't move via a touch although it does move programmatically, i.e., tapping a partially obscured option scrolls it to the middle of the screen.
I did subclass the scroll view and confirmed it was receiving touches by overriding touchesShouldBegin. Any idea of a change in iOS 13 that might cause this behavior?
Turns out the issue isn't with the scroll view but with the segmented control. In iOS 13 you can swipe/pan to change the selected segment which prevents the scroll view from scrolling. The solution is to subclass the control, override
gestureRecognizerShouldBegin and paradoxically return true.class NoSwipeSegmentedControl: UISegmentedControl {
override func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
return true
}
}
Here's a link to the relevant posting on stack overflow: https://stackoverflow.com/questions/58177165/ios-13-segmented-control-remove-swipe-gesture-to-select-segment