title: Adding label programmatically in UITableViewCell?
body: <p>I'm having a problem adding an extra label on some of my cells in the tableview. At the moment I determine the rowheight as follows:</p>
  
  <pre><code>override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -&gt; CGFloat {
          let numberOfBusses = nearbyStops[indexPath.section].getDepartures()[indexPath.row]!.count
          if (numberOfBusses &gt; 2) {
              return CGFloat((75/2) * numberOfBusses)
          } else {
              return 75
          }
  }
  </code></pre>
  
  <p>I try to do this to add the missing label, but nothing happens:</p>
  
  <pre><code>override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -&gt; UITableViewCell {
      let cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as! BusDepartureTableViewCell
      let numberOfBusses = nearbyStops[indexPath.section].getDepartures()[indexPath.row]!.count
              if (numberOfBusses &gt; 2) {
                  var label = UILabel(frame: CGRectMake(0, 0, 200, 21))
                  label.center = CGPointMake(160, 284)
                  label.textAlignment = NSTextAlignment.Center
                  label.text = "I'am a test label"
                  label.textColor = UIColor.redColor()
                  cell.foregroundView.addSubview(label)
              }
  
  
  .........
  </code></pre>
  
  <p>What am I doing wrong?</p>
  
  <p>UPDATE:</p>
  
  <p>I've taken a picture of my current achievements and I've gotten the cell to expand, however, as you can see, there's now room for two other labels, but how do I add them?</p>
  
  <p><a href="https://i.stack.imgur.com/0tWoQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0tWoQ.png" alt="enter image description here"></a></p>