After NavigationBar Hide on Swipe, Cells appear between HeaderCell & Status Bar for a second

旧时模样 提交于 2019-12-08 00:02:06

问题


Edit: I tried adding in AppDelegate DidFinishLaunch..

let view: UIView = UIView.init(frame: CGRectMake(0, 0, UIScreen.mainScreen().bounds.size.width, 25))
view.backgroundColor = UIColor.redColor()
view.alpha = 1
self.window!.rootViewController!.view.addSubview(view)

After I changed the Status Bar to red, I prevented it going under status bar, but I realised that it wasn't just the Status Bar and there was something going on with the Navigation Bar while it gets swiped away. The content cells get shown until 1 seconds after NavBar gets swiped away. After 1 seconds, everything seem nice and no content cell gets over the header cell or status bar.

To clear up the problem, at the time Navigation Bar swipes away, there is a gap forms between Header Cell and status bar, so content cells appear for 1 seconds.

But how can I prevent this 1-2 second bug? It's the header cell that gives a gap for 1-2 seconds. It mostly occur if I swipe/roll the table view down fast.

I am leaving the original question below for the future readers.


Original Question:

I have a TableViewController that has Header & Content cells. I am hiding Navigation Controller on Swipe. However, after hiding Nav Bar, Content cells' content goes under the status bar at the top. Everything else is fine.

Header Cells seem fine, as they stop right below Status Bar.

  • Extend Edges - Top Bars should be checked for the header cell to stop going under status bar but unfortunately doesn't stop content cell.

I tried:

  • self.tableView.contentInset = UIEdgeInsetsMake(20, 0, 0, 0). However, this gives a space between Header Cell & Status Bar (even before the Navigation Bar gets hidden). I want to achieve after hiding the Nav Bar.

  • self.extendedLayoutIncludesOpaqueBars = false does nothing.

  • self.automaticallyAdjustsScrollViewInsets = false Using this anchors the HeaderCell to the top of the view so HeaderCell gets positioned under NavigationBar.

  • self.edgesForExtendedLayout = UIRectEdge.None. Using this made the HeaderCell position itself starting from the top of Status Bar so half of the Header seems under status bar. (Also Navigation Bar - Bar Tint forces to become dull gray ignoring whatever I choose, so not really convenient)


I want to ask

  • Is there a way to not to make Status Bar opaque & make it solid? (I have the Status Bar - Inherred on Storyboard).

  • Otherwise, is there a way to prevent this behaviour? Maybe considering status bar solid; or maybe giving the Header Cell a space or position HeaderCell starting under the Status bar after the Navigation Bar gets hidden?



回答1:


I had no luck getting it with TableViewController, here is my workaround...

  • Created a new ViewController

  • Unchecked 'Adjust Scroll View Insets'

  • Copied the TableView from TableViewController into ViewController's View.

  • Added constraints to TableView (Top/Bottom/Left -20/Right 20).

  • In AppDelegate, give white colour to Status Bar.



来源:https://stackoverflow.com/questions/36509535/after-navigationbar-hide-on-swipe-cells-appear-between-headercell-status-bar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!