Search code examples
iosuitableviewuiscrollview

UITableView is not showing inside a UIScrollView


I have in my View a long UIScrollView (about 1000 px in height), and at the end of this UIScrollView I have a UITableView.

The cellForRowAtIndexPath is never called (surely i checked the delegate and datasource if they are connected right, and the IBOutlet of the table is strong) but numberOfRowsInSection is getting called.

I tried reloading the TableView when the UIScrollView scrolls so when the table is at focus the cellForRowAtIndexPath might get called, but with no luck.

Did anyone encounter a similar behaviour when trying to use tableview and scrollview together?


Solution

  • Your hierarchy is like this:

    A parentView is there. Inside the parent view there is a scroll view and there is a table view. So, your tableview is somewhere at 1000 from origin of parentview.

    So, tableview will never become visible to your parentview and no delegates will be fired.