1
votes

Looks like iOS makes our life difficult for simple things that should be accomplished in seconds with auto layout.

Anyway I want to place a UITableView inside a UIScrollView (I know that tableview contains scrollview but this is not what I want). The View ierarchy is

  • OuterView
    • ScrollView
      • ContainerView
        • View 1
        • TableView

The expected result is to disable tableview functionality and the scrollview to scroll view1 and tableview together. The problem is that the height of the scrollview is the devices height whatever the device orientation. If i change the tableview frame and content size to the one calculated by all rows it does not adapt to the scrollview content size. Why? What's auto layout doing then?

I have set constaints like Trailing-Leading-Top-Bottom spacing to all view as well as width and height equality between outer and container view.

I cannot find a SIMPLE tutorial for scenarios like this one.

1

1 Answers

2
votes

The Apple documentation discourages embedding UITableView within a UIScrollView because it can cause unexpected behaviour:

You should not embed UIWebView or UITableView objects in UIScrollView objects. If you do so, unexpected behavior can result because touch events for the two objects can be mixed up and wrongly handled.

This is likely why you are having trouble finding a tutorial. Why do you want to embed a table inside a UIScrollView? It may be more effective to designate rows in the UITableView to act as the content you wish to put in the UIScrollView.