Search code examples
iosswiftuinavigationcontroller

scroll up tableview to hide half of navigation bar and the whole table gets offset


I'm using a UITableViewController embedded in a navigation controller, I've checked the "hide bars on swipe" for the navigation controller in the storyboard. No crazy code, scrollview functions are not overridden, didn't write any code that would offset any views.

When I scroll up the tableview a tiny bit and release it when the navigation bar is half hidden, the whole table gets offset and it's off screen (sometimes the top left corner of the table is visible), then if I scroll up the table view a bit, it's back to its normal position, if I check "adjust scroll view insets" in the storyboard, the whole screen flashes black.

Has anyone encountered the same problem? p.s. I'm using Xcode 9 beta with iOS 10.3, not sure if this has anything to do with it.

EDIT:

Scroll navigation bar half way

enter image description here

The view after releasing

enter image description here


Solution

  • So I created a new set of TableviewController and NavigationController, and tested it step by step by adding changes to it, it turned out that I had set my navigation bar to be translucent in the storyboard, once I unchecked it the issue was resolved. There's still an unwanted bounce effect if I release the navigation bar at half hidden position, which appears to be the view adjusting the offset, but it's way better than what it was like.

    P.S. make sure "Adjust scroll view insets" is checked.

    EDIT:

    Turns out setting extendedLayoutIncludesOpaqueBars to True also resolves this issue, if you want to keep the navigation bar opaque.