title: Automatically change cell height based on content - Swift
body: <p>Using a UITableView in Swift, could someone please help me automatically change the height of the cell based on the label, picture, and description please?</p>
  
  <p>All of the information passes through correctly, I just need help formatting it.</p>
  
  <p>I tried adjusting it using <code>cell.frame.size.height</code>, but that had no effect. I could change the size of the cell in the storyboard, but I would like it more dynamic if possible.</p>
  
  <p>Thank you in advance!</p>
  
  <p>My cell is as follows:</p>
  
  <pre><code>override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -&gt; UITableViewCell {
          let cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as! UITableViewCell
  
          // Creator
          let creator = self.photos[indexPath.row].creator
          let user = UILabel()
          user.frame = CGRectMake(self.headerView.frame.origin.x, self.headerView.frame.origin.y + self.headerView.frame.height + 3, self.view.frame.width, 12)
          user.text = creator
          cell.addSubview(user)
  
          // Photo
          let picture = self.photos[indexPath.row].image()
          let imageView = UIImageView(image: picture!)
          imageView.frame = CGRectMake(user.frame.origin.x, user.frame.origin.y + user.frame.height, self.view.frame.width, 400)
          imageView.contentMode = UIViewContentMode.ScaleAspectFit
          cell.addSubview(imageView)
  
          // Photo description
          let description = UITextView()
          let des = self.photos[indexPath.row].photoDescription
          description.frame = CGRectMake(imageView.frame.origin.x, imageView.frame.origin.y + imageView.frame.height, self.view.frame.width, 65)
          if des != nil {
              description.text = des!
              description.font = UIFont.systemFontOfSize(16)
              description.editable = false
              description.scrollEnabled = false
          }
          cell.addSubview(description)
  
          cell.frame.size.height = user.frame.size.height + imageView.frame.size.height + description.frame.size.height + 30
  
          return cell
      }
  </code></pre>