mercredi 24 juin 2015

How to programmatically add a UITableViewController to a UINavigationViewController?

I have

class SortViewController: UINavigationController{

 var myBtn: UIBarButtonItem?
 var tvc = UITableViewController()

override func viewDidLoad() {
    super.viewDidLoad()

        myBtn = UIBarButtonItem(title:"Press Me", style: UIBarButtonItemStyle.Plain, target: self, action: "doStuff:")

        tvc.navigationItem.leftBarButtonItem = sortBtn
        self.pushViewController(tvc, animated: true)
        tvc.tableView.reloadData()
    }

with all the necessary override func tableView(...) functions below.

This is all in a popover view that is called by a different view. While the popover opens, and myBtn appears properly on the navigation bar on top of the table, the table does not populate as it should. - that is, it does not populate at all.

Any ideas why?

Note everything in my app is completely programmatic; no storyboard whatsoever - this is intentional.

Thanks in advance,

Jona

See more ..

Aucun commentaire:

Enregistrer un commentaire