Skip to content

Instantly share code, notes, and snippets.

@jpbyrne
Last active August 29, 2015 14:23
Show Gist options
  • Save jpbyrne/507907140b2d6abc5654 to your computer and use it in GitHub Desktop.
Save jpbyrne/507907140b2d6abc5654 to your computer and use it in GitHub Desktop.
Updating TableView Height Constraint
@IBOutlet weak var tableView: UITableView!
@IBOutlet weak var tableViewHeightConstraint: NSLayoutConstraint!
var tableViewCell: UITableViewCell = tableView.cellForRowAtIndexPath(NSIndexPath(forRow: 0, inSection: 0))
var cellHeight: CGFloat = tableViewCell?.frame.height
var dataSource: [AnyObject]?
tableViewHeightConstraint.constant = calculateTableViewHeight(cellHeight, dataSource.count)
tableView.setNeedsLayout()
tableView.layoutIfNeeded()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment