1

I have a UIViewController in swift/ios 8.

In that view I have added two UITableView (Not UITableView Controller)

I have successfully loaded data from JSON web request.

I have added these tableviews within scroll view.

Now I want to make increase the height of the UITableView to fit all the rows. I do not want the UITableView to scroll. The UIView should be scrolled, with the Scroll View.

I have tried increasing size, also tried using sizeToFit method on the table view.i

Ali Sakhi
  • 195
  • 1
  • 1
  • 9

1 Answers1

0

Instead of using two separate UITableViews inside of a UIScrollView, use one UITableView with multiple sections.

The UITableViewDelegate protocol provides ways to use headers (tableView:viewForHeaderInSection:) and footers (tableView:viewForFooterInSection:) to create custom UI between the sections as needed.

Dan Nichols
  • 469
  • 2
  • 5
  • Thakns Don. I have used the same technique now. But can I have different UITableViewCells for each section. Plus I need some header and footer content on the View, e.g. Title and an Image. Is this possible? and How? – Ali Sakhi Sep 14 '15 at 07:35
  • Use a different reuse identifier for each custom cell type (see http://stackoverflow.com/questions/11659263/multiple-uitableviewcell-classes-in-one-uitableview). You can create the header and footer as headers and footers for the table sections using the above delegate methods. – Dan Nichols Sep 15 '15 at 03:34
  • Thanks Don. That was helfpful – Ali Sakhi Sep 16 '15 at 11:43