iOS ChildViewController in UINavigationController = show StatusBar - ios

I have stumbled across a weird problem when implementing a view container which is connected with child view controllers.
The hierarchy is the following:
I have a UISplitViewController and in the MasterViewController I added a view container which is connected to a UIViewController which is embedded in a UINavigationController.
The outcome is the following:
The ChildViewController leaves a white space at the top which seems to be exactly as high as the status bar. How can I avoid that the status bar frame is shown in the child view controller?
I tried to set wantsFullScreenLayout for the ChildViewController and for its UINavigationController but it doesn't change anything.
I also tried to set the y offsets of the views to -20.0 points but that ends up in another problem.
Only when I set status bar hidden for the application it is not shown for the ChildViewController but that in turn also hides the status bar at the top of the UISplitViewController.
Would be glad for some hints.

Basically it looks like the top gap is the status bar. The statusbar at the moment is 'light' colored which is why it's not showing on top of the white background. Try changing the background color of the view controller to black or use one of the appearance callbacks to change the status bar to a darker color.

Related

Why is there a white area where my iOS Status Bar is supposed to be

I created a new view controller and connected it up in an existing storyboard. I can see the status bar on all the preceding screens, but not on this one. There is just a white bar where it should be. I'm not doing anything to hide the status bar!
I have no idea why, but the base view of my view controller was not transparent. When I made the background color of the base view of the view controller transparent, I could see my status bar again.

UINavigationController background issue in UISplitViewController that is embed in UITabBarController

I want my SplitViewController to be embedded in TabBarController. I started with a Single View Application. Then I used storyboard to connect all controllers as shown on this image.
The navigation works fine, but the problem is at the top and bottom bar background colour. I would like to use Translucent Black Navigation Bar and Tab Bar. For some reason, the background colour of Navigation Bar and Tab Bar in master view is grey instead of purple (colour of master view background). In detail view the colour is fine. Problem is clearly seen on this image.
I tried to manually set the colour of NavigationBar but it didn't help.

How to contain UIViewController view between navigation bar and tab bar?

I have created a storyboard layout which contains UIViewControllers within UINavigationControllers which all connect back to a UITabBarController. There is a login page which is not connected to anything (just a UIViewController) which segues into the UITabBarController when the app detects user authentication. You can see what this looks like in the following image:
When I set the translucent property of the Navigation Bar to "false" or "No", the view y origin gets pushed down to the bottom of the Navigation Bar (which is the behavior that I am looking for). However, when I set the translucent property of the Tab Bar to "false" or "No", the Tab Bar DOES become opaque, but the view is not resized to fit between the top and bottom bars. I have unchecked the Extend Edges property for both Under Top Bars and Under Bottom Bars for all UIViewControllers, UINavigationControllers, and the UITabBarController.
When I add subviews programmatically (no auto-layout), the UIViewController's view is still the height of the entire screen, and is only pushed down from the top bar, but not pushed up from the bottom bar. While creating this question, this is the result I got on the simulator (subviews are not even starting below the Navigation Bar):
The layout that I'm trying to achieve is to have the view fit between the Navigation Bar and the Tab Bar so that both bars are opaque and no content goes underneath them. Any ideas or suggestions?
EDIT:
After eliminating individual Navigation Controllers and adding a single one before the TabBar Controller, I'm getting weird behavior including navigation items disappearing and one of my subviews still goes under bottom bar.
EDIT 2:
After doing some research, It seems that having navigation controllers inside each tab is a normal view hierarchy. Unfortunately, I still have not figured out how to limit a view controller's view to be between a navigation bar and a tab bar. Any suggestions?

UIPageController inside UINavigationController is offset from the top?

This a little bit wierd i have made UIPageController that works and everything is fine. But when i put it inside UINavigationController, it offset from the for status bar. Than i swipe up on that screen it positions itself right and everything is ok. I don't really understand what is happening. Here are the images
try setting adjustScrollViewInsets to false on UIPageController.
This is the property that determines whether the system should automatically add inset to a UIScrollView in your view controller's view hierarchy when it is being displayed behind transparent bars (here , the navigation bar). What happened here is that the system assumed the bounds of the page controller overlaps with that of the nav bar and so it adds insets so that the view's contents is fully visible and is not obscured by the nav bar. But in this case it is wrong since it seems your page controller's bounds starts at the bottom edge of the nav bar.
I think you can also set the nav bar as opaque to disable the automatic adding of insets.

View controller not autoresizing when status bar reappears

With the status bar initially visible, I add a subview and hide the status bar:
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
[myController.view addSubview:anotherController.view];
In this view there is a button to toggle the status bar visibility, but when I set statusBarHidden to NO again, the view controller's view doesn't auto resize to take into account the status bar, and as a result the view is pushed down and cut off by 20px. I've set all the appropriate resizing masks to the view and also tried auto-layout, but neither seem to work. I'd like my view to resize automatically when showing/hiding status bar without manually setting its frame.
Update
Instead of adding it the root view controller's view, I've pushed it onto the stack of my navigation controller, and hidden the status bar and navigation bar. I then give the user the option to toggle only the status bar. However the problem still remains and the view is pushed and cut off by 20px when the status bar reappears.
But when I rotate the device, everything is in its place - only if I rotate the device after the status bar has been hidden.
How is myController added to the window? Assuming that myController is the rootViewController of your window, than this controller should resize correctly when displaying / hiding the statusBar. The view of anotherController should be added in another way, than just adding its view. But still, if you give that view the correct resizing flags, it should also resize. But it would be better, if you push that controller on a navigationController, or if you set it as the new rootViewController.

Resources