2016-09-26 37 views
-1

我想動態更改所選行的高度。表視圖行高不適用於iOS

該文檔說heightForRowAtIndexPath:是這樣做的最佳方式。

我到目前爲止在這裏。檢測水龍頭,但該行的高度不會改變:

override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { 
    func tableView(tableView: UITableView, heightForRowAt: IndexPath) -> CGFloat { 
     return 490.0 
    } 
// print("helloworld") 
} 
+0

不要把heightForRow *放在* didSelectRow裏面。將它放在符合表視圖委託的對象上並重新加載didSelectRow上的表。 – JAL

回答

1

你不執行didSelectRowAt:方法裏面heightForRowAt:方法。您需要在選擇該行時更新數據模型,然後指示表重新加載該行。然後,您的heightForRowAt:的實現將根據您的數據模型爲給定的indexPath返回適當的高度。

相關問題