For adding a view to a UITableViewController I added the view to navigationController as below:
self.navigationController?.view.addSubview(view)
view.translatesAutoresizingMaskIntoConstraints = false
view.rightAnchor.constraint(equalTo: (self.navigationController?.view.rightAnchor)!).isActive = true
view.bottomAnchor.constraint(equalTo: (self.navigationController?.view.bottomAnchor)!).isActive = true
view.widthAnchor.constraint(equalToConstant: 70).isActive = true
view.heightAnchor.constraint(equalToConstant: 120).isActive = true
But when you want to push a new ViewController it will keeps the added view (myView).
I tried to add myView to view and tableView like below:
self.view.addSubview(myView)
self.tableView.addSubview(myView)
but both doesn't work.
I know I can use UIViewController and add a UITableView and then it is easier to add myView to UIViewController.
Should I add myView to another view?