Changing UINavigationController Back Button Image Issue - ios

I am trying to change the navigation controller back button, but am facing problems with the image not being inline. I have removed the text by clicking on the navigation Item in the view controllers and changing the back button text to a single space " ".
Then I change the navigation bar back image to my custom one in the Navigation Controller scene.
But the image is not inline.
Does anybody know why this is or what are the best practises to change the back button image.

Id suggest you take a look at your image and make sure the back arrow is correctly positioned in the image. That may be what is causing it look like it is push upwards.
Alternatively, you could use:
[[UINavigationBar appearance] setTitleVerticalPositionAdjustment:(float)0.0 forBarMetrics:UIBarMetricsDefault];
Which would change the vertical positioning of your title to match the image. However, it may the make your rightBarButtonItem to look out of place.

Related

Back button showing as different colour on screen?

To experiment with the back button in a navigation controller set up, I added a button programmatically without using storyboard and without using the default navigation bar and back button you get for free with the navigation controller.
In App Delegate I simply said:
navigationController.isNavigationBarHidden = true
I set the button to a simple black and white image icon - but when I run it in the simulator the image shows as blue.
Does anyone know why this might be? It seems to still be picking up the navigation controller colour of blue but I have set the NavigationBarHidden to be true.
from assets, make sure the photo is selected and go to attributes inspector and change “render image as” to Original, same applies for tab bar items images

Navigation bar changes height after segue

I have an issue with my app that I can't solve. I have a FirstViewController with a button. when this button is pressed a SecondViewController is pushed. The issue is that the navigation bar changes its height in the secondViewController like (GIF above)
I didn't write code related to the navigation bar, I checked everything I could think about and tried to delete the segue and re-add it. How can I solve that?
The only thing I found is this answer but it didn't work for me
It looks like it is making space for a 'prompt' message that appears above the navigation bar as your GIF shows. As you've said you haven't added any code also check the storyboard in case you have entered just a space (as we obviously can't see any text) in the navigation bar prompt box as shown below. Click navigation bar in your view and look at the inspector:
If there is obviously no space, add text and re-delete it.

Navigation Bar is resetting when pushing a ViewController

I have a little problem with my navigation bar, when I push a view, the image logo title disappears. And I would like that the logo stays at its position :
what is the best way to keep the image into my navbar ?
The UINavigationItem (where you have probably set the logo as titleView) is specific to a single view controller. This makes sense, because the title is usually supposed to describe the content of one view controller. Have you tried setting the same titleView on your second view controller? This will definitely keep the logo visible on the detail screen, however, I'm not sure if the transition is completely seamless or if it fades out/in or slides in some way.
First you need to hide the navigation item in first view controller by using-->
self.Navigation Controller.Navigation item.hidden=yes;
Then in second View Controller configure your "logo" and Corresponding "Title" by placing image view and label.
by doing this you can achieve your requirement.

Back Button Different on Different Navigation View Controllers

I have searched and can't figure out what is going on.
I have a NavController set up to root on VC1 which has a push segue to VC2. On VC2 the stock back button is just the Arrow Icon (no Arrow Icon with "Back Text).
In a different part of my app I have another Navigation Controller set up to root on VC5 which pushes to VC6. On VC6, the stock back button is the Arrow Icon with the "Back" text).
I am trying to be uniform but I can't figure out how to change these without loading in my own images (which I really don't want to do). I have tried to look for differences between the Navigation View Controllers but can't find how they are different.
Preferably I would just like the Arrow Icon without the "Back" Text.
Anyone experience this?
Another solution: You can control the text on the back button by setting the title of the view controller you came from.
self.title = #"my title";
And this text will appear on the back button of the next view controller you will navigate to. (Unless you defined an image for the back button)
This is not the best solution, (I prefer faviomob's solution using the storyboard, or programmatically), but it can be convenient in some cases.
Look at my picture. When I select any cell in the table view (in root view controller), the second view controller pushed with '111' back button. So, to have empty text there just set it to whitespace.
To set just the back arrow set the left bar Button item of the Navigation bar. Follow this:
//Set the back image. Use ur own image instead of back.png.
UIBarButtonItem* leftBarButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:#"back.png"]
style:UIBarButtonItemStylePlain
target:self
action:#selector(leftBarButtonPressed)];
[self.navigationItem setLeftBarButtonItem:leftBarButton];

Why can I not drag UIBarButtonItem onto navigation bar?

I'm having a little bit of an issue. When I place the UIBarButtonItem on the tab bar controller it works perfectly, it displays as it should:
However, I can't put a button onto where the black square is. Does anyone know how I could do this non-programatically?
You should probably add a Navigation Item by dragging it from the Object Library to the place where you have marked in black and then try adding a Bar Button Item on the right. It should work
UINavigationBar wants only UIBarButtonItem. You can create one with custom View programmatically. Show here: https://stackoverflow.com/a/16058345/717193

Resources