Question

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.

Was it helpful?

Solution

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.

OTHER TIPS

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

MyAppDelegate *delegate = (MyAppDelegate *)[UIApplication sharedApplication].delegate;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top