iOS - Tabview 分成不同 Group
當我們想將 TabVIew 分為2個 Group 時, 如 已搜尋到的藍芽裝置和已連接上的藍芽裝置, 可利用 Header 或 Footer來分隔.
Step 1: 在主畫面中拉進TableView , 並在 TableView中拉進 TableView Cell
Step 2: 繼承 UITableViewDataSource Protocol 並實做
群組個數
由於目前我們要分成2個Group, 所以設置為兩個sections
1 | func numberOfSectionsInTableView(tableView: UITableView) -> Int { |
群組名稱
此範例利用 Header來設定名稱
1 | func tableView(tableView: UITableView, titleForHeaderInSection section: Int) -> String? { |
各群組資料數量, 在此我們先設定為0
1 | func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { |
設定TableViewCell
在.storyboard中, 設定參考 Cell 名稱
1 | func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { |
iOS - Tabview 分成不同 Group
https://nickcarter9.github.io/2016/07/07/2016/2016_07_07-ios-tableview_diff_group/