views:

64

answers:

2

Hello Guys,

I'm creating an iphone app with few elements inside the controller (e.g tab bar, uiview, uitoolbar, etc..). Everything works fine until I encountered this problem. While my application is launched, I received a call and it shows the "Call Status Bar" which ruined the ui. Some elements are pushed down because the "Call Status Bar" is taking space at the top.

Anybody here have an idea on how to fix this issue? I'm new to iPhone app development.

Your reply is greatly appreciated...

Best Regards,

A: 

Basically what you normally do is try to set up the autoresize flags of all your ui elements in interface builder so that when the main view is "squashed" by the call status bar everything will still look reasonable. It's a little hard to explain how to do all of this in one message, but I recommend creating a view in IB, placing some subviews in it, then resizing the main view while playing with the autoresize flags to get a feel for how the flags work. The autoresize flags are in Command-3 (size inspector).

You can also set wantsFullScreenLayout in the main view controller to YES to cause the view to take up the whole screen, including the area under the status bar, but then you'll have to make sure not to place anything under the status bar and the call status bar will overlap anything too close to it, of course.

Nimrod
+2  A: 

You should put this function on appDelegate, this will trigger when the status bar change

    - (void)application:(UIApplication *)application didChangeStatusBarFrame (CGRect)oldStatusBarFrame 
{
       NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
       [dict setObject:@"trigger" forKey:@"frame"];

       [[NSNotificationCenter defaultCenter] postNotificationName:@"trigger"
                                                    object:self
                                                  userInfo:dict];
}

This Code will send Notification with the name "trigger"

Place a code to your view Controller (e.g: viewDidLoad, etc..) this listen if there are notification send with a name "trigger"

[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(dataReceived:)
                                             name:@"trigger"
                                           object:nil];

And create a function dataReceived:

- (void)dataReceivedNotification:(NSNotification*)notification
{
    NSDictionary* data = [notification userInfo];
    // do something with data
}

do something on this part of the code, maybe you change the frame of your tab bar, uiview frame, toolbar frame

And in delloc, put this code to remove the observer

- (void)dealloc {
    [[NSNotificationCenter defaultCenter] removeObserver:self];
    [super dealloc];
}
dianz
This works for me... Thanks
samer