:UI Master-Item #
で
は、あなたのセクションヘッダもあります。だから、UILabelをとり、それをセクションヘッダーとして追加します。
サブアイテムは、1つのラベルを含むprtotype-cell
セルです。
セル内のラベルの制約。あなたのcell
で
- 次のように最初の制約に
UIView
を追加します。
- トップ、ボトム、
0
としてsuperView
につながる、ボトム。
- ラベルを追加し、次のように制約を与えます。
- 上側、下側、下側、
UIView
として8
。
- 要件に応じて高さの制約を与えます。
=
から>=
までの高さの関係を指定します。
- storyboardから
label
プロパティ行を0に設定します。
はdelegate
とのtableViewのdataSource
をバインドすることを忘れないでください
//MARK:- TableView
public func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat{
return 60 // return header height
}
public func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
// return your section header i.e. master item label
}
public func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat{
return 50;
}
public func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat{
return UITableViewAutomaticDimension
}
public func numberOfSections(in tableView: UITableView) -> Int{
// return number of section i.e. total count of master item.
}
public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int{
// returns number of cells in each section
}
public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell{
// return your custom cell here
//eg:
// cell.labelFood.text = your data
}
NOTEにこのラインを実装します。
私たちにあなたの 'prototype-cell'画像を見せてください。 –
ここで必要なビューを更新しました... – PPreeti
拡張可能なtableViewを実装しようとしていますか? – iDeveloper