Search code examples
iosswiftuitableviewuiscrollviewscrollview

How to disable elastic scrolling in nested scrollview


I have a tableView containing various views, where some might be subclass of UIScrollView. In some cases, such as when user drags on nested scrollView, which is currently at the top, it correctly scrolls the main tableView, however the rubber band effect is applied also to the nested subView.

Is there a way to disable this behaviour? So that rubber band effect is applied only to the main scrollView, but the nested one stays as it is?

EDIT: Preferably while keeping bounces se to true.


Solution

  • You can set bounces to your scroll view subclasses at init or setup. Btw, Apple does not recommend nested scroll views, be careful with simultaneous gestures handling.