我正在使用以下代码将scrollldown tableview改为底部:
let numberOfSections = tableView.numberOfSections()
let numberOfRows = tableView.numberOfRowsInSection(numberOfSections-1)
let indexPath = NSIndexPath(forRow: numberOfRows-1, inSection: 0)
tableView.scrollToRowAtIndexPath(indexPath, atScrollPosition: .Bottom,
animated: true)
它运行良好,但除非我使用以下行,否则我的代码无法正常工作。
tableView.estimatedRowHeight = 44
我该如何解决这个问题?
答案 0 :(得分:6)
看起来您需要将行高设置为自动尺寸。看看这篇文章 http://natashatherobot.com/ios-8-self-sizing-table-view-cells-with-dynamic-type/
要设置自定义单元格,只需将AutoLayout添加到单元格中,指定tableView的estimatedRowHeight,并将tableView的rowHeight设置为UITableViewAutomaticDimension(这将是未来XCode6版本中的默认设置)。
tableView.estimatedRowHeight = 89
tableView.rowHeight = UITableViewAutomaticDimension