0
votes

We have a problem where the user is using our app on the iPhone and receives a call while on a view that has been presented by the rootviewcontroller and is covering the navigation controller and it's nav bar. The status bar for the call shows and pushes the current view down but when that view is removed from the superview, the status bar covers half of the navigation bar.

We have tried using a UIApplicationWillChangeStatusBarFrameNotification in the app delegate and then adjusting the size of the navigation controller and the navigation bar to no effect. We have also tried resetting the frame of the navigation controller and nav bar in the viewWillAppear function of the page that presents the view.

Can anyone tell us where we are going wrong?

In App Delegate we tried this

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[self setupAppStyles];

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.backgroundColor = [UIColor ugBlue];
UINavigationController *navController = [[UINavigationController alloc] init];
self.window.rootViewController = navController;

[self.window makeKeyAndVisible];

[self setUpNotifications];

return YES; }

-(void) setUpNotifications {
[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(statusFrameChanged:)
                                             name:UIApplicationWillChangeStatusBarFrameNotification
                                           object:nil];}

- (void)statusFrameChanged:(NSNotification*)note {
CGRect statusBarFrame = [note.userInfo[UIApplicationStatusBarFrameUserInfoKey] CGRectValue];
self.statusHeight = statusBarFrame.size.height;

UIScreen *screen = [UIScreen mainScreen];
CGRect viewRect = screen.bounds;

viewRect.size.height -= self.statusHeight;
viewRect.origin.y += self.statusHeight;

[[UINavigationBar appearance] setFrame:viewRect];

NSLog(@"The status frame has changed");

//[self.navController.view setFrame:viewRect];


self.navController.view.frame.size.height);}

We have also tried something similar in the views viewWillAppear functions also with no positive results. Any thoughts?

1

1 Answers

0
votes

We were able to solve this problem. In the viewDidAppear of the view that called presentViewController we put

   CGRect screenRect = [[UIScreen mainScreen] bounds];
   CGFloat navBarHeight = self.navigationController.navigationBar.frame.size.height;
   CGRect frame = CGRectMake(0.0f, statusSize, screenRect.size.width, navBarHeight);
   [self.navigationController.navigationBar setFrame:frame];

When the status bar is shown