2
votes

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.

enter image description here

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) enter image description here


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
You could set up the constraints so that the table view does not overlap with the status bar.Blip
For the table view? Constraints seem disabled for Table Viewsenty
have you considered hiding the status bar?user3353890
@user3353890 I want to keep the status barsenty

1 Answers

0
votes

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.