How do I detect a double-height status bar? - iphone

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

Related

How to handle alignment of UI on phone call?

I am developing iPhone app for iOS 5 or above version, and making use of storyboard for UI design. My problem is when i am on phone call my UI gets misaligned because my upper status bar is taking 20 to 30 pixel of screen space.
How to handle my UI when i am on phone call?
I finally got answer for my question. Following are the things i made changes in my project and everything started working fine.
Took sliced images of all the things needed in my UI. (Initially
i was taking common image to save slicing time)
Made you of autoResizingMask property. It help me save my lots of time. Just make sure only 3 arrows top, left and right one is in ON state and your work is over.
For making everyones search easy i will add following Stackoverflow links to save your time
How to position view below green bar during phone call?
Resize for in-call status bar?
How do I detect a double-height status bar?
How to Remove Status Bar in "View Based Application" - iOS
how to hide status bar in Iphone application
How In-Call status bar impacts UIViewController's view size ? (and how to handle it properly)
iPhone Programming In Call Status Bar
resize content after iPhone status bar is shown/hidden
How to programmatically get iOS status bar height
How is the in-call status bar impacting my CGAffineTransform'd view?
View resize when In-Call Status Bar changes
Thanks to all the people who have replied to all the questions above. It made my big problem resolved.

What are the iPhone activities that change the height of the status bar?

What activities/events trigger the height of the status bar to change on the iPhone?
For example: When an application is visited while in a phone call the height of the status bar [[UIApplication sharedApplication] statusBarFrame] is 40 instead of it's normal height of 20.
The iOS Simulator has an option Hardware>Toggle In-Call Status Bar. When that is selected the UIApplicationWillChangeStatusBarFrameNotification and UIApplicationDidChangeStatusBarFrameNotification are posted.
What user actions and/or phone actions cause this to happen? Are there any activities besides phone calls that cause the status bar to be taller than 20 pts?
#Bogatyr is right, Internet tethering is one.
Audio recording (such as with the voicememos.app) is another.
Internet tethering becoming active is another such activity.
Also turn-by-turn navigation in a map app.
You'll see "Google Maps is Using Your Location" in the status bar when you use Google, and "Touch to return to Navigation" when you use Apple Maps.

Problem with hiding status bar on iphone app, screenshot included

Im getting this blue line when i try to hide the status bar, I'm using the following line in the touchesBegan method in my RootViewController
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationFade];
http://i.stack.imgur.com/GBCgX.png
Thiis is really simple. forget about coding it. just do it right at the beginning this make it a lot more simple and less messier. I do it all the time for every single application I've created.
Go into your project in xcode, then in the Groups and Files section find a file called yourapplicationname-info.plist.
Double cick that and a box opens. It contains properties for your file in the form of a table. Click on the last row once so that the last row is highlighted in blue. Click on the plus arrow on the right end. This will add a new row. A list appears, scroll down to Status bar is initially hidden and click enter to select it. Then an empty box appears next to the name. Tick the box and click CDM+S to save the plist. close the box and get back into xcode. Now take your code off where you try to hide the status bar.
Then click on the view, the .xib file and click with your mouse the actual view so it is in focus (the window that we are currently looking at). Then hit cmd+3 to open up the attributes section. Where it says status bar select the option and select unspecified. Now this will get rid of the status bar on the uiview. What might happen after selecting that optiion is decrease the size of the actual view by 20 pixels. thats the height of the status bar. what you want to do is readjust the view to compensate for the missing status bar. so while still having the view in our focus. hit cmd+3 this will open up the view size. change the H (height) from 300 to 320. And this will readust the screen by adding the 20 pixels which we lost by removing the status bar. Then save and close interface builder and youre done.
Hope this helps
Let me know if it does. Thanks
PK
If your view controller is embedded in a nav controller:
[CODE]self.navigationController.navigationBar.frame = CGRectOffset(self.navigationController.navigationBar.frame, 0.0, -20.0);[/CODE]
Put that in the view did load method on the first view controller your app sees. Finally a solution to this frustrating problem!!!!!
It looks like you have to adjust you view to take up the space formerly occupied by the status bar. You can probably do this using springs and struts in Interface Builder, or you can adjust the view's frame just before or after your call to setStatusBar: withAnimation:.
k then you have to do in appdelegate class
[application setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
it works fine for me... hope this will help you≄

Button has moved upwards when running app in Simulator

I have a strange problem when developing for the iPhone
There is one window (in green) and one view (in orange)
when I try to test my app it looks like this in the iPhone Simulator
you can see the view have moved upwards
is this normal? and how to solve the problem?
many thanks
You're most likely adding the view incorrectly. You could post some code and I could give you a better idea, or if you just want a quick fix, open the orange view in Interface Builder, make it 480 px tall instead of 460, show the simulated status bar and relayout your image.
In Interface Builder you can specify the simulated User interface elements. In the screenshots above you will notice in the green one you can see the status bar and the red one doesn't have it. You can turn on these elements by setting the properties of the view. Press Command-1 when you have the view selected and you will see a list of simulates ui elements you can add, these include the status bar, navigation controller bar and a few others i cant remember off the top of my head. This will allow you to position your ui elements correctly when you have these other elements on the screen.
The other issue with your view is that it is not the same height. have a look at the dimensions (cant remember exactly which one but its Command-2, 3 or 4 when you have the view selected) it should be 320x480, i reckon yours is 320x460... (20 pixels, the height of the status bar)

How to achieve a hidden status bar using three20 framework

I'm using the TTThumbsViewController section of the three20 framework, and I have the status bar hidden throughout my application.
When the user views the full size image, taps the screen(hiding the controls), when they tap again the controls reappear but the status bar is there too.
I've searched through the whole library and been unable to isolate the section where this is happening. I'd love it if someone could point me in the right direction.
Thanks,
BB
I found it hiding in the UIViewControllerAdditions.m which is called by the TTPhotoViewController.m
UIViewControllerAdditions.m
- (void)showBars:(BOOL)show animated:(BOOL)animated {
//[[UIApplication sharedApplication] setStatusBarHidden:!show animated:animated];
This doesn't seem to be it whatsoever. Or at least you did not answer your original question. The showBars is not used to show or hide the status bar but rather to show and hide the navigation bar items.
Unless of course you are talking about adding that bit of code you have commented to the showBars. That code does not even appear in my version of Three20 code.