Home > OS >  Is it possible to scroll a Scroll View layered on top of a UITableView?
Is it possible to scroll a Scroll View layered on top of a UITableView?

Time:09-17

I have a child View Controller within a Container View that hosts a vertically-scrolling UITableView. Tapping a Button expands a separate View that covers the UITableView in the child View Controller. This new View contains a vertically-scrolling Scroll View. No matter what UITableView settings I change, I am unable to scroll the Scroll View unless I remove the UITableView entirely.

I am currently porting my fully-developed Android application to IOS, and my experience with Android Studio leads me to believe that this is an issue with the UITableView stealing focus from the Scroll View.

In short, how may I temporarily remove focus from the background UITableView to allow the overlaid Scroll View to scroll?

CodePudding user response:

I assume you're adding the scroll view as subview to your table view, that's why it works this way

Try making you Container View plain UIView, and add both UITableView add UIScrollview as subviews.

CodePudding user response:

With Scroll Views up until this point, I have been setting the bottom -> Superview constraint to priority: 249 since I was having issues setting the contentSize. For some reason, having a Table View in the background disables this effect. My guess is that this happens because the Table View is forcing the Superview to anchor based on its own constraints, and therefore the Scroll View can no longer adjust based on low-priority constraints. Changing the Equal Height parameter of the Scroll View -> Superview to a proportional relation (x2) has temporarily addressed the problem.

  • Related