UIToolbar push view issue - iphone

I've created a UIToolbar and added it as a subview of the navigationController. The problem is it doesn't disappear when I do push so I hide it on push but the makes it just disappear which makes it look tacky. I thought about animating it but I am finding it hard for the animation to be exactly like the push and pop animation for the navigation controller.
Does anyone know the push and pop animation properties so it can be exactly the same, or does anyone know what view or what property i can do to push and pop the toolbar with the navigation controller.
As a note I also tried to use the toolbar that comes with the navigationController but the buttons were disappearing after popping back to the view.

Yup, check out the hidesBottomBarWhenPushed property of the UIViewController that you are push/popping.

Related

UINavigationController Push Segue - Strange animation

I have a UINavigationController which was created in Storyboards, and connected with push segues for each view controller. However, when I click "next" (which activates the push segue), then animation going forward is strange. (See: https://www.youtube.com/watch?v=0cFo9sUtBeM). Going back (Selecting the root controller of the UINavController in the UITabBarController) has the correct animation though. Any ideas why this could be?
Edit: the boxes in the video are added by me to protect client identity. The animation issue detailed is the slide animation which appears to come from the top right (or top left for the 'next' button).
It appears that setting a different Prompt for the navigation bar on the second view controller causes this weird animation effect. After removing the prompt, the animation now works as expected.
It looks like a navigation controller push and a modal transition. If I had to wager, I'd guess you have a modal transition hooked up to the button in storyboard, and code in the action method for the button doing a pushViewController:animated: on self.navigationController - (either that or the other way around, with a push hooked up in storyboard).
If that's the case, start by commenting out any button action code (any target/selector you setup in code, or any IBAction you setup in storyboard for that button).
I also recently had this problem using a Master Detail storyboard with an embedded Navigation Controller. The issue was fixed when I changed the Background of the View of the Detail screen from Default to a different color. I found it did not make any difference which color as long as it was not Default. I hope that this helps someone.

How to set modal segue animation the same as push segue animation?

There are four kinds of animations provided by apple with the modal segue. But neither is my favorite, I prefer the animation like the push segue animation? How could I archive it? Is there any open source code for custom segue with different animations? Thanks in advance!
ps. Actually I have a tabView with several child view, one of them is a tableView, each cell will drill in an detail view. It is normal to push the detail view, but I do not want the tab bar come into the detail view as well. Then I choose modal the detail view. But i prefer the push animation.
After seeing your comment I figured this would help. There is a setting to hide your tabBar when pushing instead of you having to fake a push with a modal transition.
Also in code can be easier. Check out this SO Hiding UITabBar when pushing a UIView

View sizing with setting navigationbar to hidden with push/pop

So before I push a new viewController onto the stack in a certain view, I set the navigationBar to hidden I notice that it disappears before the next screen gets pushed and the slide animation happens (because I need a UIToolbar at the top).
So question #1: is there a way to push a new view controller and setting the navigationbar to hidden, and not getting the hide animation until after the new view controller is on screen. it looks funny that the navigation bar hides then pushes the new view controller.
Once the new view controller is present, when I pop it off, I set the navigation bar back
[self.navigationController.navigationBar setHidden:NO];
But when it is popped, the navigationbar is not back any more. Is it because this navigationBar is for the current navigationController and not the new one that is being presented after the pop? (question #2)
Question 3: Realizing it isn't showing my navigationBar, in the viewController that gets presented after the pop, in its viewDidAppear, I added
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[self.navigationController.navigationBar setHidden:NO];
}
which shows the navigationBar, but the view size is incorrect since it seems like once the navigation bar was hidden, the rest of the view took up the empty space, and then the navigationBar is on top of the content. Is there anything I can do about this? Or am I approaching it incorrectly with push and pop?(question #3).
Thanks!
I was running into the very same problem (only in reverse: I was starting from a NavigationBar being hidden and pushing a view where I wanted the NavigationBar visible), and there's actually an extremely easy fix.
Simply replace your calls:
[self.navigationController.navigationBar setHidden:NO];
with
[[self navigationController] setNavigationBarHidden:NO animated:YES];
In my code, I call these statements in the - (void)viewWillAppear:(BOOL)animated methods of each respective View Controller.
I just tried this solution in the order you are using (visible, then hidden), and it seems to work just as well.
Interesting issue. You could try changing the hidden property in viewWillAppear and viewWillDisappear, but it seems like that might not give the desired results either.
Can you present the view controller modally instead of making the navigation bar disappear? If it's the last view controller on the stack, that would be possible. It might also make more sense to the user to see a view controller presented differently. This might indicate to the user that navigating away from this view controller is no longer done with the Back Button. It could be more reasonable than having the navigation bar just disappear.
If you still wanted the view controller to slide in from the right, I don't think it can be done with a modal view controller. But, you could do that by animating a view that fills the screen. (You just add the view with a frame that has origin.x equal to the width of the screen. Then, in the animation, you change origin.x to 0.0. Let me know if you need more detail on this.)
However, I would recommend presenting the view controller in a different manner from the way a view is generally presented by a navigation controller. Because, essentially, you are no longer letting the user navigate away from this view as he/she generally would from within a navigation controller. (So, my response to question #3 would be 'yes'.)

iPhone Dev - Is it possible to remove a button from a UINavigationController's navigationBar?

When I push a view via my app's navigationController, it automatically puts a back button on the left side of the navigationBar. Is there any way I can just remove this? (I want to put my own buttons on the screen that will allow the view to be popped).
From the comments, you can hide the back button for a viewController by using its navigationItem property. (which is the UINavigationItem corresponding to that viewController in the stack of the navigationController. its how you control what shows up on the bar for specific view controllers (see Apple Doc here)).
To answer your question, set the navigationItem's hidesBackButton property to YES. Something like this probably called in your viewControllers viewDidLoad: or similar method.
myViewController.navigationItem.hidesBackButton = YES;
have you try with self.navigationItem.hidesBackButton=YES;?
If I wanted to do it, I'd hide the Navigation bar on push (non animated hide), add a toolbar, and add any custom stuff I want to the toolbar.
on popping the view controller, make sure to unhide the navigation bar. It'll work

Getting empty view and blank navigation bar when I use popViewControllerAnimated

I'm writing an iPhone app that is based on a UINavigationController. I'm pulling data from a server that sometime returns bogus links. I open each link by pushing a webview viewcontroller. I want to be able to include some error handling. I know if the link is no good. So I want to be able to pop the webview view controller as soon as I know that my webview has encountered an error.
Currently, I've tried using the following code:
[self.navigationController popViewControllerAnimated:YES];
I then get a Navigation bar with nothing displayed in it, but if I click where the "back" button should be it operates appropriately. The title pops up when I click where the "back" button should be. The view where the viewcontrollers usually display there content is blank white too even though I'm popping back to a UITableViewController.
I've tried this as a workaround:
UINavigationController *nav = self.navigationController;
[self.navigationController popViewControllerAnimated:YES];
[nav.visibleViewController.view setNeedsDisplay];
I've checked the viewControllers array in the UINavigationController and it has the right viewcontrollers in it (ie it has removed the viewcontroller for the webview).
I also tried putting code in the viewWillAppear of the viewcontroller I'm popping back to, but the method is never getting called.
I'm looking for a way to force the UINavigationController to reload the same way that you can call reloadData on a UITableView.
Any help would be greatly appreciated.
I saw something like this on my app where I was using a navigation bar I added in Interface Builder on the root view of a navigation controller and then programmatically creating the nav bar and its subviews for the second view. When I would pop the second view to return to the first view I would hide the self.navigationcontroller bar which would show the white space underneath until the IB nav bar of the previous view appeared. To fix this I decided to stick with programmatically creating all my navbars which fixed the issue for me.
TL;DR - if you are using both IB and programmatically made navbars this can happen when popping views, stick with one or the other for all the navbars yo