Within 2 days I try to solve this. I just want to add a footer (user cell) in my tabular view. I have a view with some things on it (shortcuts, buttons), and I added a table view. To have a clean controller, I use a separate file for the data source:
class MyDataSource: NSObject, UITableViewDataSource, UITableViewDelegate {
...
}
In my controller, I:
class MyViewController: UIViewController {
@IBOutlet weak var myButton: UIButton!
var myDatasource: MyDataSource!
@IBOutlet weak var myTableView: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
myDatasource = MyDataSource(....)
myTableView.dataSource = myDatasource
}
So in MyDataSourceI added:
func tableView(tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
let footerView = UIView(frame: CGRectMake(0, 0, tableView.frame.size.width, 40))
footerView.backgroundColor = UIColor.blackColor()
return footerView
}
func tableView(tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
return 40.0
}
And this piece of code is not called. I looked at the documentation and I found that these last two methods are part UITableViewController, not part UITableViewDataSource.
So my question is: how to achieve this?
Thank.
c.c.
source
share