0

coming from a TableView, I am creating an MKMapView. I want to have more screen real estate, so I hide the status bar und set the navigation bar to transluscent.

[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationFade];

self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
self.navigationController.navigationBar.translucent = NO;

Unfortunaltely the navigation bar is positioned below the hidden status bar (see picture).

enter image description here

I already found out that this might help, since one can perform kind of a reload of the bar in the main event loop:

[self performSelector:@selector(setNavigationController:YES) withObject:nil afterDelay:0.1];

But this doesn't work so far. Any hint?

Thanks in advance.

brainray
  • 12,512
  • 11
  • 67
  • 116

2 Answers2

1

Okay, I found out what to do:

[self performSelector:@selector(setNavigationController:NO) withObject:nil afterDelay:0.1];
[self performSelector:@selector(setNavigationController:YES) withObject:nil afterDelay:0.1];

This switches the navigation bar off and on again, which forces it to redraw in the correct position.

Arthur Neves
  • 11,840
  • 8
  • 60
  • 73
brainray
  • 12,512
  • 11
  • 67
  • 116
  • `setNavigationController:` is probably a private API, did you manage to get this approved by Apple? – ySgPjx Jun 08 '12 at 16:28
  • no, in the end I took it out because there where more workarounds required to get this to work perfectly in my app - which was not possible within the given time. – brainray Jun 21 '12 at 10:40
0

I use this in iOS 6:

self.navigationController.navigationBarHidden = YES;
self.navigationController.navigationBarHidden = NO;
KONG
  • 7,271
  • 6
  • 28
  • 27