I'll find a solution here in Objective-C, but it is not working for me. I would like to hide my 'NavigationBar' in my 'TableViewController' when I scroll down. I have done it this way:
override func viewDidLoad() {
super.viewDidLoad()
self.navigationItem.title = "Test"
self.navigationBar = UINavigationBar(frame: CGRectZero)
self.view.addSubview(navigationBar)
self.navigationBar.pushNavigationItem(self.navigationItem, animated: false)
func layoutNavigationBar() {
self.navigationBar.frame = CGRectMake(0, self.tableView.contentOffset.y, self.tableView.frame.size.width, self.topLayoutGuide.length + 44)
self.tableView.contentInset = UIEdgeInsetsMake(self.navigationBar.frame.size.height, 0, 0, 0)
}
override func scrollViewDidScroll(scrollView: UIScrollView) {
self.layoutNavigationBar()
}
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
self.layoutNavigationBar()
}
Any ideas what is wrong here? The 'NavigationBar' appears on load, but never disappears.