I have table view to display comments of users
I need to make height of each row dynamic depending on content height
i searched for it and i found
heightForRowAtIndexPath Method
but it's not working or i don't know how to use it !
here's my code :
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath)
let username = cell.viewWithTag(1) as! UILabel
let comment = cell.viewWithTag(2) as! UITextView
username.text = usernames[indexPath.row]
comment.text = comments[indexPath.row]
return cell
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.comments.count
}
func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
return UITableViewAutomaticDimension;
}