-1

I want it so that my navBar doesn't sit on top of my table view but instead is separate from it, so each tableView cell is displayed in equal proportions. As it is, I can't seem to change it, I have tried adding it manually, programtically and tried to change it in the view hierarchy, which I am unable to do. I imagine there is a straightforward solution to this I just can't work out what that is? Below is my code.

override func viewDidLoad() {
    super.viewDidLoad()

    let navigationBar = UINavigationBar(frame: CGRectMake(0, 0, self.view.frame.size.width, 44)) 

    navigationBar.backgroundColor = UIColor.whiteColor()
    navigationBar.delegate = self
    let navigationItem = UINavigationItem()
    navigationItem.title = "Title"
    let leftButton =  UIBarButtonItem(title: "Save", style:   UIBarButtonItemStyle.Plain, target: self, action: "btn_clicked:")
    let rightButton = UIBarButtonItem(title: "Right", style: UIBarButtonItemStyle.Plain, target: self, action: nil)

    navigationItem.leftBarButtonItem = leftButton
    navigationItem.rightBarButtonItem = rightButton

    navigationBar.items = [navigationItem]
    self.view.addSubview(navigationBar)

}
Jamie Baker
  • 157
  • 6

1 Answers1

0

I had the same problem. A solution is just using a standard view controller and then adding table view and navBag. Instead of trying to add a navBar on top of a tableviewcontroller. Im quite new to swift but i hope this answer helps.

tarjerw
  • 101
  • 1
  • 1
  • 8