Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How In-Call status bar impacts UIViewController's view size?

I'm trying to understand how the view associated to a UITabBarController, UINavigationController or UIViewController reacts when the in-call status bar is toggled.
My trouble is that they seem to behave differently and this causes me side effects.

I've made a project that changes the root view controller of the window for the 3 types above and I dump the description of the view to get the frame coordinates.


  • UIViewController

enter image description here

inCall status OFF:

UIView: 0x4e2a1f0; frame = (0 20; 320 460); autoresize = W+H; ....
ON
UIView: 0x4e2a1f0; frame = (0 40; 320 440); autoresize = W+H; ...

This one I understand : when the in-call status bar appears, the height of the view of the UIViewController shrinks and looses 20, and its y coord moves from 20 to 40.

That's perfect ! I would expect the same when replacing a classic UIViewController with a UITabBarController or a UINavigationController but that's not the case !


  • UINavigationController

    enter image description here

InCall status bar OFF

UILayoutContainerView: 0x4b35ab0; frame = (0 0; 320 480); autoresize = W+H; ..
ON
UILayoutContainerView: 0x4e1b060; frame = (0 0; 320 480); autoresize = W+H; ..

In that case, the view handled by the UINavigationController does not have its frame properties changed when the in-call status bar is toggled?! (why ? :( )


  • UITabBarController

enter image description hereOFF

UIView: 0x4b2f6a0; frame = (0 20; 320 460); autoresize = W+H; ...
ON
UIView: 0x4b2f6a0; frame = (0 20; 320 460); autoresize = W+H; ...

Same as in the UINavigationController: the view of the UITabBarController does not seem to be impacted when the incall status bar is toggled.


Can someone explain me how this resize works when displaying the incall status bar appears ?
My end goal is to display a UIView that is shown ABOVE the whole UITabBarController and that resizes properly when the in call status is displayed. However, I really don't know where to put such a view in the views hierarchy : if I add it as a child of the UITabBarController's view, as this one does not react to the incall status display, mine does not react as well :(

like image 472
yonel Avatar asked Mar 30 '11 12:03

yonel


2 Answers

The height of the view when the In-call status bar is toggled depends on the way it's anchored.

Play around with the autoResizingMask of the UIView to control whether the view should move down or resize when the in-call status bar shows up.

These two properties,

UIViewAutoresizingFlexibleTopMargin
UIViewAutoresizingFlexibleHeight  

will help you. The first one pushes the view down, the second one changes the size.

like image 83
Mugunth Avatar answered Oct 24 '22 08:10

Mugunth


Your regular UIViewController example has [wantsFullScreenLayout] set to NO, which causes the view to be automatically sized so it doesn't go under the status bar.

UINavigationController and UITabBarController, on the other hand, default wantsFullScreenLayout to YES. So their views take up the whole window, and they size and position their subviews themselves to appropriately handle the status bar. If you explicitly set the property on these controllers to NO, you should get the behavior you desire (but will then lose the ability to properly handle child controllers that set wantsFullScreenLayout to YES, if you care about that).

In your UITabBarController example, BTW, it seems that you are not printing the information for the view of the tab bar controller; here that is a UILayoutContainerView, not a plain UIView.

like image 4
Anomie Avatar answered Oct 24 '22 10:10

Anomie