tags:

views:

1447

answers:

4

How can I make my view resize in response to the in-call status bar from my nib?

I figured it would just be setting the resize properties, but they're not enabled for the root UIView.

(I think my main problem here is I don't know what any of this is called; I can't find any reference to the in-call status bar in any of the documentation except where it talks about the simulator menu command.)

+4  A: 

You're looking for -[UIApplication statusBarFrame] and, in your UIApplicationDelegate, you should implement this delegate method to be notified of when the status bar's frame changes:

- (void)application:(UIApplication *)application didChangeStatusBarFrame:(CGRect)oldStatusBarFrame
Mike McMaster
Mike, can you clarify: Does this mean I must manually resize the items on my views in code? Gasp!
Steven Fisher
I don't see why if your view's autoresizing properties are properly set. But yeah, writing code - what a horrible inconvenience. :-)
Mike McMaster
Marking the other accepted because he pointed out that what I was trying to do *should* have worked first, but thank you very much. :)
Steven Fisher
This method is not called when the status bar changes height as a result of ending a call. As far as I can tell, it is only called when rotating a view.
Jonah
+2  A: 

What do you mean when you say that 'the resize properties aren't enabled for the root UIView'?

The in-call status bar doesn't have any particular special designation, and I don't think there are any APIs or notifications around it. Instead, your views should simply be set up to autoresize correctly.

Try creating a new navigation-based app in Xcode and study the autoresize settings on the table view in RootViewController.xib. Hopefully you'll see a delta between what Apple's set and what you've set in your project.

Aaron Brethorst
I'm probably using the wrong term there, too. Basically, I have a xib with a UIView. Selecting the UIView and looking at the resize properties, I can click the top/bottom and left/right connections, but the horizontal and vertical in the center don't respond to clicks.
Steven Fisher
Created a new UIView in the xib, and I can manipulate it. Seems to be something wrong with that UIView in the xib. Will experiment a bit more and mark this as the solution if so.
Steven Fisher
Yes, it looks like something's simply wrong with that UIView. Thanks.
Steven Fisher
+1  A: 

For views like UITableView you'll typically need to change the table cell height, and there's no other way to do it except to implement application:didChangeStatusBarFrame:. But it's no biggie, and you can set the row height to non-integer values if you need to.

Scott Lahteine
Except that application:didChangeStatusBarFrame: and the accompanying notification is never sent for a simple status frame change. Try it :-)
Steve Weller
I noticed that when I got around to trying it. So how do we handle the change in screen size? My app's interface slides down but gets partially obscured in the process.
Scott Lahteine
A: 

The solution is to ensure you have made your window key:

[window makeKeyAndVisible];

If you don't do that the subview does not get resized automatically, but there are no other symptoms as far as I know.

Steve Weller