views:

190

answers:

2

I want to know when the status bar changes height as a result e.g. of a phone call in progress. So I put the following in my UIApplicationDelegate:

-(void)application:(UIApplication *)application willChangeStatusBarFrame:(CGRect)newStatusBarFrame {
    NSLog(@"yup, got here");
}

and indeed when I toggle the in-call status bar on the simulator from any screen in the application, the message appears in the console, but what I want to do is to move a uitextfield or 2 in another class since the double-height status bar is messing up one screen in particular. I've had no luck with autoresizing on this screen.

So my question is how do I go about implementing code for one screen and one screen only from this method in the AppDelegate? It fires in all screens but I only need it in one. Ideally I'd like a method only in the one class to fire.

+3  A: 

The system will also post a UIApplicationWillChangeStatusBarFrameNotification at the same time. Have your view controller listen to this notification. No need to mess with the app delegate at all.

Ole Begemann
Thanks. I'll give it a try. So I don't even need the method in the app delegate. Great!
Matt Winters
Works perfectly. Thanks again.
Matt Winters
+1  A: 

Go with Ole's answer, but for future reference, how you get to your delegate is:

MyAppDelegate *delegate = (MyAppDelegate *)[UIApplication sharedApplication].delegate;
Dan Ray
Thank you. Good to know.
Matt Winters