I have a UITableViewController that currently displays 4 cells that will always be displayed, and would like to group them together, but I cannot figure out how to do this. The resources I found give only instructions using Interface Builder when a standard UITableView is pasted on top of a UIViewController or something like that. How can I group them programmatically?
Here is my current UITableViewController class:
import UIKit
class SecondViewController: UITableViewController {
let Items = ["Altitude","Distance","Groundspeed"]
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.Items.count
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var cell:UITableViewCell = self.tableView.dequeueReusableCellWithIdentifier("cell") as UITableViewCell
cell.textLabel?.text = self.Items[indexPath.row]
return cell
}
override func viewDidLoad() {
super.viewDidLoad()
self.tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: "cell")
}
}
source
share