简体   繁体   中英

How do I detect a double-height status bar?

The HIG (p.47) says that I have to be able to handle the double-height status bar that appears during phone calls or voice recordings.

How exactly do I handle this situation?

I really only have 1 screen where a keyboard with toolbar over it underlaps a textfield when the double-height status bar shows - on other screens things are just a bit scrunched up but useable.

If I could detect that a double-height status bar exists, I could maybe adjust the placement of the textfields or make them temporarily shorter but is it possible to detect when the double-height status bar is there?

EDIT: Maybe if there were a way to get the absolute coordinates of a known thing, like the nav bar, and if it was +20 pixels off, I'd assume that the double-height status bar is present. Thoughts?

And a secondary question, if this (or anything) works, I'd just like to hide the regular status bar using

[[UIApplication sharedApplication] setStatusBarHidden:YES animated:NO]

but I don't want to hide both - basically a lazy way not to have to touch any of my screens - if the double is there, make it a single again by hiding the regular status bar. Will the above code hide both?

You can monitor these call-backs of UIApplicationDelegate:

  • application:willChangeStatusBarFrame:

  • application:didChangeStatusBarFrame:

And it's easy to test this in the iphone simulator: Hardware->Toggle In-Call Status Bar

Depending on your situation, your views and the things in them can resize automatically to fit the space - check the View Size area of the inspector window in Interface Builder on various objects

This issue also occur when user use many other utilities like hotspot. To solve this issue I use following line of code ( as I was myself stuck in this ).

self.tabBarController?.tabBar.autoresizingMask = UIViewAutoresizing(rawValue: UIViewAutoresizing.RawValue(UInt8(UIViewAutoresizing.flexibleWidth.rawValue) | UInt8(UIViewAutoresizing.flexibleTopMargin.rawValue)))

Objective C reference for same issue available here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM