Hide navigation bar, but when I transition to the previous view (popped) it shows the old back button temporarily. Why?
Hide navigation bar, but when I transition to the previous view (popped) it shows the old back button temporarily. Why?
I have view controllers in a navigation controller (root: RootViewController
, second: ReadingViewController
), but in the second view controller I want to disable the navigation bar for a UIToolBar
(as I don't need the title and want more buttons, like in iBooks or the Facebook app). Problem is, when I hide the navigation bar in the second view, it appears randomly for a second again when I pop the view controller (go back).
When I pop the view controller the back button appears for a second:
In the second view controller I hide the nav bar in viewWillAppear:
:
- (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; [self.navigationController setNavigationBarHidden:YES animated:YES]; }
Also in the second view controller, I restore the nav bar in viewWillDisappear:
:
- (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; // ... other stuff [self.navigationController setNavigationBarHidden:NO animated:YES]; }
I'm wondering how I combat this issue so that the view controllers transition seamlessly.
Answer by matt for Hide navigation bar, but when I transition to the previous view (popped) it shows the old back button temporarily. Why?
The problem here is that viewDidLoad
is way too soon! Remember, viewDidLoad
does not have anything to do with the interface and the actual push animation. It does not mean that this view controller's view is about to appear on screen! It merely means that the view controller has obtained its view.
I made a video, showing what happens on my machine as I move back and forth between two view controllers in a navigation interface, one of which shows the navigation bar, the other does not: http://youtu.be/PxpchytWQ4A
To me, that's as coherent as you are going to get when showing and hiding the nav bar as you push and pop! Here's the code I used. The view controller that hides its nav bar is of class ViewController2. This code is in the app delegate:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. dispatch_async(dispatch_get_main_queue(), ^{ [(UINavigationController*)self.window.rootViewController setDelegate:self]; }); return YES; } -(void)navigationController:(UINavigationController *)nc willShowViewController:(UIViewController *)vc animated:(BOOL)animated { [nc setNavigationBarHidden:([vc isKindOfClass:[ViewController2 class]]) animated:animated]; }
That's all I did.
Answer by Malathi for Hide navigation bar, but when I transition to the previous view (popped) it shows the old back button temporarily. Why?
In the second view controller hide the nav bar in viewWillAppear::
self.navigationController.navigationBar.frame = CGRectMake(0, 0, 0, 0);
For unhiding the navigation bar set the frame in viewWillDisappear:
self.navigationController.navigationBar.frame = CGRectMake(0, 0, 320, 44);
Answer by Yuvrajsinh for Hide navigation bar, but when I transition to the previous view (popped) it shows the old back button temporarily. Why?
Hello The following stuff done my job
In FirstViewController
put this method
- (void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; [self.navigationController setNavigationBarHidden:NO animated:YES]; }
and in SecondViewController
put this method
- (void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; [self.navigationController setNavigationBarHidden:YES animated:YES]; }
I have not used viewWillDisappear
for my work done.
Hope will help you.
Answer by Ayush for Hide navigation bar, but when I transition to the previous view (popped) it shows the old back button temporarily. Why?
Hey why don't you use navigation bar as a UIToolbar
.
Instead Of hiding UINavigation
you can mimic navigation controller to UITootlbar
by adding buttons to it.
hiding unhiding UINavigation
would be complex.
I am Uploaded the dropbox link.
Answer by patric.schenke for Hide navigation bar, but when I transition to the previous view (popped) it shows the old back button temporarily. Why?
It could be as simple as moving your code from viewWillDisappear
to viewDidDisappear
.
Also, avoid using animations in any view*appear methods, as the view-transition is already being animated.
Answer by Andrey Chevozerov for Hide navigation bar, but when I transition to the previous view (popped) it shows the old back button temporarily. Why?
Well, as I understand from your question the only problem of your current approach is temporary appearance of original "Back" button. So why not just block this button for the view controller?
self.navigationItem.hidesBackButton = YES;
I think it might help. But for your main task I'd rather suggest you to use custom navigation bar with ability to add as many buttons as you want. Such approach is more natural for iOS and you'll probably never face the issues like you mentioned in your question.
Answer by user1785898 for Hide navigation bar, but when I transition to the previous view (popped) it shows the old back button temporarily. Why?
MY problem is that when I push a viewController with a navigationBar onto one without it by using a customised transition moving it from the left side, I am not able to have it follow the second view controller's frame. It always drops from above producing a very unpleasant effect whenever I perform this action.
Fatal error: Call to a member function getElementsByTagName() on a non-object in D:\XAMPP INSTALLASTION\xampp\htdocs\endunpratama9i\www-stackoverflow-info-proses.php on line 72
0 comments:
Post a Comment