我在快速設置tableview單元格行高時,在滾動行高變化時,請檢查屏幕快照。 Tableview根據swift中的內容動態設置行高?
它第一次滾動完成多次滾動的高度並不合適。我使用了太多的自定義的tableview細胞 在viewDidLoad中 我加入這個
self.tableView.rowHeight = UITableViewAutomaticDimension
,並還增加了這些委託的方法。
func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat
{
return UITableViewAutomaticDimension
}
func tableView(tableView: UITableView, estimatedHeightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat
{
return UITableViewAutomaticDimension
}
任何人都可以指導我以正確的方式實現這一目標。
請把這個放在你的** cellForRowAtIndexPath **方法中'yourLabel.numberOfLines = 0'和 'yourLabel.sizeToFit()' – iDeveloper
這不是帶有一個標籤的。我用了兩個很多標籤。 –
你有沒有給圖像和標籤之間的適當限制? – iParesh