"scrollsToTop" not working even though only one UIScrollView subclass has "scrollToTop" set in view hierarchy

94 Views Asked by At

There are a slew of topics on this site with similar questions, but no matter what I do I cannot get scrollsToTop working in my app:

  • set scrollsToTop=false in every scrollView subclass except one
  • set it to false in every one, add a new scrollView behind other views, give it a content offset and a large contentSize, no change (its delegate gets no message)
  • walk every subview from my 'view' looking for UIScrollView subclasses, none are set

My view structure is complex - childViewControllers, custom headers, etc. I just cannot find any way to get this feature to work.

1

There are 1 best solutions below

0
David H On

Well, I have to give credit to a Q&A not on SO for the clue: most every other solution has suggested walking the view hierarchy from the current view down, but this author says to walk if from the window down.

When I did that, I found the culprit: the hidden master view in my UISplitViewController (the app's root view controller) has a table, and that table had scrollsToTop set to true.

I changed it to false, and voila - now I get a working scrollsToTop!