1
votes

I created a ViewController with TableView inside it and embedded it a NavigationController. I also set the constraints. On Swipe down, Navigation Bar hides. Everything seems fine.

The only problem is that on Swipe Up, the Navigation Bar doesn't come back.

If I use the same TableView with a TableViewController instead of ViewController (embedded from the same Navigation Controller), the Navigation Bar does comes back.


For the ones wondering why I don't just go with the TableViewController, because I need to uncheck Adjust Scroll View Insets for some disturbing bug.

2
Maybe you should post some code.ryantxr
It was done from the Storyboard.senty
it seems like this same issue stackoverflow.com/q/24710258/4975761wj2061

2 Answers

3
votes

To solve the issue, I used scrollViewWillEndDragging and detected Going Down & Going Up

func scrollViewWillEndDragging(scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) {

   if targetContentOffset.memory.y < scrollView.contentOffset.y {
       // UP
   } else {
       // DOWN
   }
}
1
votes

Here's my solution, based on senty's answer:

func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) {

    let draggDelta = scrollView.contentOffset.y - targetContentOffset.pointee.y

    let hiddenContentHeight = spreadsheetView.contentSize.height - spreadsheetView.frame.height - 1

    if 0 < draggDelta && targetContentOffset.pointee.y < hiddenContentHeight || (targetContentOffset.pointee.y == 0 && scrollView.contentOffset.y < 0) {

        // Shows Navigation Bar
        navigationController?.setNavigationBarHidden(false, animated: true)
    }
}