2016-06-28 74 views
0

我有一個想在Xcode中實現的概念。它是一個具有3個Prototype單元的默認TableViewController。帶3個原型單元格和自動高度的Swift tableView

Cell 1 = name (Prototype Pages) 
Cell 2 = seperator (Prototype Seperator) 
Cell 3 = only ImageView (Prototype Seperator-with-only-image) 

小區1和小區2是好的。我需要將所有「Prototype Seperator-only-only-image」單元的高度設置爲自動。高度應根據添加的圖像尺寸進行計算。

這裏我樣機

enter image description here

Addional信息:「原型分隔符 - 用只圖像」可以出現多次,圖像的尺寸可以變化。

任何想法,我可以如何實現這一點?

回答

0

您可以設置的tableview的rowHeight等於UITableViewAutomaticDimensionviewDidLoad方法:

self.yourTableView.rowHeight = UITableViewAutomaticDimension 
    self.yourTableView.estimatedRowHeight = 42.0 

在這裏,你告訴你的tableview計算row的尺寸。 然後你說你估計row將有42的高度,基本上設置最小高度。

我認爲this是一個很好的使用演示程序的例子。

相關問題