Automatic cell size in Swift

1
Hello, I have a project that has a tableview with custom cells, until Swift 1.1 method tableView.rowHeight = UITableViewAutomaticDimension in viewDidLoad and number of lines in 0, were already enough for my adapt to the character content contained in them. But after Swift 1.2 they do not fit in anymore, could anyone give me a light on this?

    
asked by anonymous 07.06.2015 / 21:17

1 answer

1

It also places the estimated size (Value that is realistic for you, a general case just to "speed up" computing):

tableView.estimatedRowHeight = 100
tableView.estimatedRowHeight = UITableViewAutomaticDimension // Talvez isso funcione no momento não tenho como testar.

If the problem persists, implement these UITableViewDelegate methods:

func tableView(tableView: UITableView!, heightForRowAtIndexPath indexPath: NSIndexPath!) -> CGFloat {
    return UITableViewAutomaticDimension
}


func tableView(tableView: UITableView!, estimatedHeightForRowAtIndexPath indexPath: NSIndexPath!) -> CGFloat {
    return UITableViewAutomaticDimension
}
    
07.06.2015 / 21:23