Question

I have UIScrollView with other UIView elements inside. My other UIView elements are mostly segmented controls. If I click on a UISegmentedControl and hold for a second and then try to scroll, then no scrolling happens. I can only scroll when my finger touches and swipes immediately. I checked other iOS applications such as mail. The behavior was that you touch and hold on a mail, then it's highlighted, but as soon as finger moves away, the scrolling happens and highlighting is undone. How can I implement this behavior?

Was it helpful?

Solution

The issue was the property of UIScrollView. The property canCancelContentTouches was set to NO. Because of that, touch events were handled by subviews of scroll view and swiping didn't cause scrolling.

OTHER TIPS

You can follow one of these steps:

  1. If you are using UISegmentedControl over you UIScrollView, instead of that, add the UISegmentedControl over your controller's view.

  2. If you want to use UISegmentedControl over your scrollView, then you have to create a custom scrollView by creating a subclass of UIScrollView and use an image view instead of UISegmentedControl adding the labels which can act as the segments. This is because your UISegmentControl itself is a touch handler and it breaks the UIResponder chain. So, the scrolling might face issues during the touch events.

Please let me know if any of these works. Thanks :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top