我試圖在選擇自定義單元格時調整標籤的高度(以允許其展開以使更多文本可見)。更改didSelectRowAtIndexPath中的自定義單元格的標籤高度
我很明顯缺少一些基本的東西,雖然因爲在我嘗試繪製新的CGRect後框架完全相同。
下面是相關代碼:
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
let indexPath = tableView.indexPathForSelectedRow()
let currentCell = tableView.cellForRowAtIndexPath(indexPath!) as! BasicCell
UIView.animateWithDuration(0.3) {
tableView.beginUpdates()
currentCell.subtitleLabel!.frame = CGRectMake(currentCell.subtitleLabel!.frame.origin.x, currentCell.subtitleLabel!.frame.origin.y, currentCell.subtitleLabel!.frame.size.width, 100)
currentCell.subtitleLabel!.numberOfLines = 0
tableView.endUpdates()
}
}
任何幫助,將不勝感激。
嘗試添加一個布爾到您的自定義單元格,並在heightForRowAtIndexPath方法設置的高度與細胞contentSize.height否則tableView.rowHeight –