2

I am having a lot of issues with layout due to double high status bar on iPhone. My layout is organized in a way giving the required size for all UIelements, resizing them all in order to handle the double high status bar makes my app layout look ugly in normal use.

Please can anyone suggest if there is any alternate way to handle the layout being pushed downwards out of the screen when double high status bar appears? and in normal use (no double high status bar) UI still looks good?

Rash
  • 31
  • 3
  • What is a double high status bar? – Mick MacCallum Nov 02 '12 at 13:26
  • Double high status bar is what you get when using the app while answering a phone call or while using the iOS built in tethering. – miho Nov 02 '12 at 13:37
  • 1
    If you use Autoresizing masks or Auto Layout then the relative layout of your UI will remain the same but just adjust to be smaller. If you use neither then the UI will not adjust to changes in the screen bounds and will look ugly. So my suggestion is to make sure you use Auto Layout or set your Autoresizing masks correctly. – Robotic Cat Nov 02 '12 at 13:50
  • you can check [this other answer](http://stackoverflow.com/questions/3947226/iphone-how-to-resize-view-when-call-status-bar-is-toggled) (the one with more votes, not the selected one) it works great – samiq Jul 15 '13 at 19:59

1 Answers1

5

Typically to handle a change in screen size, Autoresize rules are very important (Autolayout is more flexible in iOS 6).

These rules define how the position and size of your elements change depending on the superview's size change. They're generic rules, that affect top/left/bottom/right margins, and width/height, but work for most people in most situations.

You need to decide what you want your view to look like with a shortened height, and take that in to account when implementing your view. If Autoresize can deal with this for you, that's great! You can apply them either in IB (under the ruler tab when a view is selected), or via code:

view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

If you're targetting iOS 6 and above, you can also use AutoLayout and its constraints system.

If this isn't suitable, then you can perform your own transformations on demand, when the status bar changes height. This can be done by either:

  1. Implementing these delegate methods in your App Delegate:

    application:willChangeStatusBarFrame:
    application:didChangeStatusBarFrame:
    
  2. Observing these notifications

    UIApplicationWillChangeStatusBarFrameNotification
    UIApplicationDidChangeStatusBarFrameNotification
    
WDUK
  • 18,870
  • 3
  • 64
  • 72