I currently have a view, uisegmentedcontrol, and another view all inside of a scrollview. The last view swaps between two uitableviews based on the selected index in the uisegmentedcontrol. To make all the elements scroll together, I make the uitableview height the same as it's content size. However, when I do that, all of the cells are loaded because they are "visible" within the scrollview even though they're not visible on the screen. If there is a large row count, this locks up the screen and is slow to load on some phones. Is there any way around this? Is there any way to make the tableview only call tableView:cellForRowAtIndexPath: when it's actually visible on the screen instead of the visible in the scroll view?
I know that using headerView and footerView is an option, but that becomes a little weird because the top view and uisegementedcontrol should be the same for both tableviews. I also have other screens where I have two uitableviews (with both of them having sibling views above and below) inside a uiscrollview and I need everything to scroll together
EDIT: Here is the layout of the screen in the screen with two UITableViews. Everything will be contained in one scroll view:
|-------------------------------|
|UIView (contains title of page)|
|------------------------------ |
|UITableView
|
|
|
|
|
|------------------------------
|UIButton
|
|-----------------------------
|
| UITableView
|
|
|
|
|
|
|
|
|-----------------------------