title: UITableView with Two Prototype Cells
body: <p><strong><em>UPDATE- Thanks to Farhad for answering my initial post. At the bottom of this post is a new issue i've encountered regarding automatic dimensioning for dynamic cell height</em></strong></p>
  
  <p>I've tried searching for other posts but to no avail.</p>
  
  <p>As the title suggests I want to have my table view show two cells with the second cell being custom.</p>
  
  <p>The first cell will have 4 rows - O.D, Weight, I.D, Grade.</p>
  
  <p>The second cell, the custom cell, will have 8 labels displaying the results from the inputs from the first cell.</p>
  
  <p>I have a reuse identifier for both cells. The first cell i've called "capacitiesCell" and my second cell I've called "cell2"</p>
  
  <p>For my second cell, I have created a new tableViewCell file named "CapacitiesTableViewCell" that has 4 of the 8 labels as outlets.</p>
  
  <p><em>SIDE NOTE: For the name of the cells I've just put a generic "Section #, Row #" for now but will change the line of code to <code>cell.textlabel?.text = capacityID</code> when I've figured the issue out...assuming that's the correct way to go about this.</em></p>
  
  <p>Here is my code thus far:</p>
  
  <pre><code>class CapacitiesTableViewController: UITableViewController {
  
  let capacityParameters = ["O.D", "Weight", "I.D", "Grade"]
  
  override func viewDidLoad() {
      super.viewDidLoad()
  
      // Uncomment the following line to preserve selection between presentations
      // self.clearsSelectionOnViewWillAppear = false
  
      // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
      // self.navigationItem.rightBarButtonItem = self.editButtonItem()
  }
  
  override func didReceiveMemoryWarning() {
      super.didReceiveMemoryWarning()
      // Dispose of any resources that can be recreated.
  }
  
  // MARK: - Table view data source
  
  override func numberOfSectionsInTableView(tableView: UITableView) -&gt; Int {
      // #warning Incomplete implementation, return the number of sections
      return 2
  }
  
  override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {
  
      if section == 0 {
          return capacityParameters.count
      } else {
          return 1
      }
  
  }
  
  
  override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -&gt; UITableViewCell {
      let cell = tableView.dequeueReusableCellWithIdentifier("capacitiesCell", forIndexPath: indexPath)
  
      //let capacityID = capacityParameters[indexPath.row]
      cell.textLabel?.text = "Section \(indexPath.section) Row \(indexPath.row)"
  
      return cell
  
      let dimensionAndStrengthCell = tableView.dequeueReusableCellWithIdentifier("cell2", forIndexPath: indexPath)
      // my code goes here
      return dimensionAndStrengthCell
  }
  
  override func tableView(tableView: UITableView, titleForHeaderInSection section: Int) -&gt; String? {
  
      if section == 0 {
          return "Casing Specification"
      } else {
          return "Dimension &amp; Strength"
      }
  }
  </code></pre>
  
  <p>This is my storyboard:
  <a href="https://i.stack.imgur.com/YKqAM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YKqAM.png" alt="enter image description here"></a></p>
  
  <p>However when I run the app I get this:
  <a href="https://i.stack.imgur.com/sPqDE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sPqDE.png" alt="enter image description here"></a></p>
  
  <p><strong>CHANGING CELL HEIGHT FOR CELL2</strong></p>
  
  <p>So in my viewDidLoad I have the following:</p>
  
  <pre><code>override func viewDidLoad() {
      super.viewDidLoad()
  
      // Uncomment the following line to preserve selection between presentations
      // self.clearsSelectionOnViewWillAppear = false
  
      // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
      // self.navigationItem.rightBarButtonItem = self.editButtonItem()
  
      self.tableView.rowHeight = UITableViewAutomaticDimension
      self.tableView.estimatedRowHeight = 200.0
  }
  </code></pre>
  
  <p>I'm trying to have my view look like the screenshot below but the "Strength and Dimension" section cell height is stuck on the default height.
  <a href="https://i.stack.imgur.com/9jBQ6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9jBQ6.png" alt="enter image description here"></a></p>
  
  <p>the new code I've added from Farhad's response is :</p>
  
  <pre><code>override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -&gt; UITableViewCell {
  
      // init return type of cell
      var returnCell: UITableViewCell!
  
      if indexPath.section == 0 { // you can also check for section with section.index
          returnCell = tableView.dequeueReusableCellWithIdentifier("capacitiesCell", forIndexPath: indexPath)
  
          //let capacityID = capacityParameters[indexPath.row]
          returnCell.textLabel?.text = "Section \(indexPath.section) Row \(indexPath.row)"
  
      return returnCell
  
      } else {
  
          returnCell = tableView.dequeueReusableCellWithIdentifier("cell2", forIndexPath: indexPath)
  
          self.tableView.rowHeight = UITableViewAutomaticDimension
          self.tableView.estimatedRowHeight = 200.0
  
          return returnCell
  
      }
  }
  
  
  override func tableView(tableView: UITableView, titleForHeaderInSection section: Int) -&gt; String? {
  
      if section == 0 {
          return "Casing Specification"
      } else {
          return "Dimension &amp; Strength"
      }
  }
  </code></pre>