Scroll to Top Gesture on Multi UIScrollView

If you have more than one UIScrollView inside a view of a ViewController (like this picture), most likely “scroll to top” gesture (by tapping on status bar) won’t cause the UITableView scrolls to toppest row.

Why is that? Inside that view there’re more than one UIScrollViews, as pointed by arrows. As we know, UITableView is a subclass of UIScrollView, so it is a UIScrollView. Inside each cells there’s a UIScrollView. When “scroll to top” gesture happens, the question is which UIScrollView to scroll?

For such UI, we want the UITableView responses to “scroll to top” gesture, while others don’t. There’s super easy solution for that. Are you ready? 🙂

Just set “scrollsToTop” property of the UITableView to YES (which is the default), and set “scrollsToTop” property of other UIScrollViews to NO. That’s it!