I am moving with Navigation bar by this method to another location:
- (void)shiftNavigationBar
{
self.navigationController.navigationBar.layer.zPosition = 0;
float currentVersion = 7.0;
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= currentVersion) {
UINavigationBar *navBar = self.navigationController.navigationBar;
[self.navigationController.navigationBar
setFrame:CGRectMake(navBar.frame.origin.x, 92, navBar.frame.size.width, navBar.frame.size.height)];
}
}
I do this in viewDidAppear
and when controller is loaded for first time it's okay. But when I click home button and returns to application navigation bar disappear (ok, it didn't disappear I have another bar in place where normally is navigation bar so it "hides" above this bar) and I need to shift navigation bar again but I tried different methods (Will/DidAppear and so) but It's looks that noone is execute when returning from inactive. I know there is method for this in AppDelegate
but what method I can use in controller?
Edit: Methods which I tried but It didn't worked:
1- Add method shiftNavigationBar to AppDelegate and call it in applicationDidBecomeActive
- (void)applicationDidBecomeActive:(UIApplication *)application
{
[self shiftNavigationBar];
}
- (void)shiftNavigationBar
{
((UINavigationController*)self.window.rootViewController).navigationBar.layer.zPosition = 0;
float currentVersion = 7.0;
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= currentVersion) {
UINavigationBar *navBar = ((UINavigationController*)self.window.rootViewController).navigationBar;
[((UINavigationController*)self.window.rootViewController).navigationBar
setFrame:CGRectMake(navBar.frame.origin.x, 92, navBar.frame.size.width, navBar.frame.size.height)];
}
}
2- Call controller method from AppDelegate
- (void)applicationDidBecomeActive:(UIApplication *)application
{
UINavigationController *navController = (UINavigationController*)self.window.rootViewController;
[(MAListRepositoriesVC*)navController.topViewController doMyLayoutStuff:self];
}
// I added shiftNavigationBar to method doMyLayoutStuff
3- Observer in controller
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(doMyLayoutStuff:) name:UIApplicationDidBecomeActiveNotification object:nil];
Everytime method was called but everytime navigation bar is back at top. It looks like methods are called too soon and after that there are next changes and returns navigation bar back to top.
Edit2: As right answer I choose answer with replace navigation bar with custom view because that's what I must do. I tried many solutions which I can find but nothing help me. So I created custom view which looks like I need and mainly which is there where I put it.