I have a UITableView for which I want to implement a custom header. In the custom header I want a button which when tap pushes a new view onto the navigationController. I am having trouble accessing the navigationController in the custom header view's super's ViewController.
class CustomViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
//setup views and whatnot
//setup delegate and datasource
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
return CustomHeaderView(type: section)
}
}
class CustomHeaderView : UIView {
let customHeaderButton : UIButton = {
let button = UIButton()
...
button.addTarget(self, action: #selector(handleCustomHeaderButtonAction()), for: .touchUpInside)
return button
}()
...
func handleCustomHeaderButtonAction(){
//push a new view onto the CustomViewController's navigationController
???
}