dimanche 19 juin 2016

Children UIViewControllers of UITabBarController overlapping Status Bar

  • Xcode 7
  • iOS Target 9.3
  • Swift 2

I have created a new Tabbed Application in Xcode:

enter image description here

I changed the background of the first template generated UIViewController super view to gray and then I run the app, as you can see in this screenshot the First UIView is overlapped by the Status Bar:

enter image description here

I have read many articles, particulary specified to iOS 7 regarding allocating space for the Status Bar.

I also read on apple.developer.com the following quote:

"Applications that use an opaque UINavigationController or UITabBarController automatically keep their content below the status bar."

In general this link on the apple.developer.com website does seem a bit outdated.

But, with that said, I am expecting the UITabBarController to load the tabbed children views with with space allocated for the status as displayed in the Storyboard for the UITabBarController:

enter image description here

I have tried adding the following to my UITabBarController class:

override func viewDidLoad() {
    super.viewDidLoad()

    self.edgesForExtendedLayout = UIRectEdge.None
    self.automaticallyAdjustsScrollViewInsets = false;
}

I have looked at many Stackoverflow question and answer threads, I found this person asking the same question on Stackoverflow: Using UITabBarController but status bar covers view

I do know how to add a constraint to the Top Layout Guide to each parent view in each UiViewController tab but I am trying to avoid adding a new top level UIView because my existing UIViewControllers tabs all have UILabels, UIButtons, UICollections, etc in the SuperView I cannot add a constraint to Top Layout Guide to the SuperView in Xcode Storyboard.

With the SuperView I cannot add a Top Level Constraint by Control Dragging it seems:

enter image description here

Aucun commentaire:

Enregistrer un commentaire