How to hide the left side navigation bar title - ios

I am navigating to another view controller from my current view controller in this way.
ViewThingsToDoViewController *vwhings=[[ViewThingsToDoViewController alloc] initWithNibName:#"ViewThingsToDoViewController" bundle:nil];
[self.navigationController pushViewController:vwhings animated:YES];
after I navigate to the new view controller it shows the current view controller title in the left side. How can I hide that?
Please help me
Thanks

Didn't work anything for me. Then I tried in this way. It worked perfectly. I wanted to hide my back button title and set a title in center of my View controller navigation bar. So in viewdidload I did something like this.
self.navigationController.navigationBar.topItem.title=#"";//make the left bar button title empty.
self.navigationItem.title=strNavigtionTitle;//make the centered navigation bar title.

The best way is to combine these, so it will hide the back button even if you set it up manually
self.navigationItem.leftBarButtonItem=nil;
self.navigationItem.hidesBackButton=YES;
OR
[self.navigationItem setHidesBackButton:YES animated:YES];

the title is acting as back button... if you hide it then how will you go back.
When you navigate from ViewController A with title say BASE to ViewController B then navigation controller as its functionality is, sets the back button label of B same name as Title of A

Related

Can't get default UINavigationController back button to work

First, I've read almost all of the questions and answers on the web and SO about navigation bar/back button/title/navigation item etc. I have a navigation controller and view controllers. Nothing fancy. Whatever I do, I can't display a back button when I push a new view controller. Neither via storyboard push segues nor programmatically pushing. My view controller and navigation bar displays correctly, when I tap where where the back button should be, it does work, it pops the view controller, however, it's not displayed.
Before you say, I'll list what I've done:
I've got the navigation controller's Shows Navigation Bar set to yes.
I've set a title to my root view controller inside the navigation controller on storyboard.
I've set a back button title to my root view controller inside the navigation controller on storyboard.
I don't have any custom code involving navigation bar/navigation item/left bar button/right bar button/hides back button/back button item.
I've set a title for my navigation controller.
Whatever I do, my back button doesn't get displayed. When I debug, it's set to nil. I've tried instantiating one but it didn't help either. What am I missing?
Firstly check that the controller you are pushing from and to has a navigation item in the viewer you can set title, back button and prompt for. I have found that depending on how storyboard has created the controller it may or may not have one you can see in the view tree. Setting the back button does not seem to work unless you can actually see one in both controllers in storyboard.
Secondly, and something I only realized recently, is that you set the title for the back button in the controller you are pushing "from" and not in the controller that will be showing when the back button is showing.
e.g. If you have controller A and controller B and you are pushing to B from A: you have to set the label for the back button in the navigationItem of controller A, not in the navigationItem of controller B. You may already know this, but its confusing.
define a property in .h
#property (strong, nonatomic) UIBarButtonItem *backButton;
in viewDidLoad in .m
self.backButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:#"backButton.png"] style:UIBarButtonItemStylePlain target:self action:#selector(backButtonPressed)];
self.navigationItem.backBarButtonItem = self.backButton;
and add the method
-(void) backButtonPressed {
[self.navigationController popViewControllerAnimated:YES];
}
oh misread... you don t want a custom button, just the normal one? maybe there is a UIBarButtonSystemItem for back ?? take this instead of a custom image...
checked tintcolor? maybe it s set to clearcolor ??
It was something much simpler. Actually, everything was acting correctly. After some investigation ([[UIWindow keyWindow] recursiveDescription]) I've realized that it was just me who was faulty to set the storyboard's global tint color to the same color with navigation bar. I've explicitly set the tint to white and now the text is seen.

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];

Tab bar controller inside a uinavigationcontroller

I have got a Tab Bar Controller inside a Navigation Controller but I cant seem to set the Navigation bar title or add a button to the navigation bar using:
self.title = #"My Name";
The code above only changes the Tab Bar Item name and not the navigation controller.
Secondly. I want to disable going back the login screen (The screen with the UIWebview over it in the screenshot)
EDIT: I found a possible duplicate
It's uncommon to put a tabBarController into a navigationController. If you can't find what's going wrong in your way try to use another way to approach what you want which is put navigationControllers into one tabBarController. Make tabBarController the initial view controller.
Not sure about the others but to set the title on the nav bar try this:
self.navigationController.navigationBar.topItem.title = #"My Title";
Although with the button in the nav bar just drag in a UIBarButtonItem from the side panel

Navigation title not showing on view with tab view controller, but "back" navigation works

I'm relatively new to iOS Objective-C development, and I've come across a problem that I can't find a solution to.
I have a Table View Controller, with two prototype cells on it, which populate fine. This Table View Controller is one of three Tab Views, and the View that sends to the Tab Views has a Navigation Controller. This means that the views within the Tab Views also have a Navigation bar. The bar works fine, in terms of the "back" button working as expected, and the bar being in position. However, (at least on the List View) the Navigation Bar isn't fully recognised - it's title doesn't appear, and the table cells start directly below the status bar, rather than below the navigation bar.
Here's a couple of screenshots showing the problem:
what appears in Xcode (what I expect to happen)
And then on the device, this is what actually appears - the Back button in place and working fine, but no title field, and the table cells start too high.
I've tried adding Navigation Bar's and Navigation Items, and while adding a Navigation Item allows me to put a title on in Xcode, it still doesn't appear on the device in testing. I also tried to add another Navigation Controller just before this view, but that didn't resolve the issue either, and it caused navigation problems further down in the heirachy.
Hope I've been clear enough, please say if I need to post more information - I'm relatively new to Xcode and so not sure what exactly is applicable and what isn't. Thanks!
please try this code, it might fix your table position
// Since in iOS7 the nav bar is translucent by default, so the table view starts at (0,0)
// you can either disable the translucent, which i don't recommend unless you really want to
// or just add 64 pixel on the top of your table view
[self.YOURTABLEVIEW setContentInset:UIEdgeInsetsMake(64, 0, 0, 0)];
and for the title, please try this
self.tabBarController.navigationItem.title =#"YOUT TITLE NAME";
Hope that helps..
Assuming your hierarchy as
NavigationController -> ViewController -> TabBarController -> ViewController1
-> ViewController2
-> ViewController3
If you want to hide navigation item in viewcontroller1, Add the following line
self.navigationController.navigationBarHidden = YES;
If you want to show title in viewcontroller2, Add the following line in
self.navigationController.navigationBarHidden = NO; //add this if you hide navItem viewcontroller1
[self.parentViewController.navigationItem setTitle:#"Title"];
If you want to hide backbutton and show title in viewcontroller3, Add the following line
self.navigationController.navigationBarHidden = NO;
[self.parentViewController.navigationItem setTitle:#"Contacts"];
self.parentViewController.navigationItem.hidesBackButton=YES;
Add this lines to viewdidAppear method instead of ViewdidLoad ,if you have problems inshowing when switching tabs.
I had the same problem, but what I did to create this problem was that my buttons action was connecting to the actual table itself and not the table Controller. I removed the modal action and created a new action to the table controller and it fixed the problem.
Try to click the Navigation Bar from your storyboard or nib.
Then add your title to the property.

ios navigation bar right button item shifts when pushing new view controller

I have a stack of three VCs that are coordinated through a navigation controller and make use of a navigation bar. On this navigation bar, in each VC, I added the same button (a 'Logout' button) as a right bar button item:
UIBarButtonItem *logoutButton =
[[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(#"LogoutButtonTitle", #"")
style:UIBarButtonItemStyleBordered
target:self
action:#selector(logout)];
[categoriesViewController.navigationItem setRightBarButtonItem:logoutButton];
[[self navigationController] pushViewController:categoriesViewController animated:YES];
So each view controller has this logout button in the navigation bar. When I push any of these controllers onto the navigation stack, the new view controllers loads as expected, everything is displayed and functions correctly, but right after the new view controller is displayed (after the animation finishes) the logout button shifts about 3px to the right.
I've tried adding the button before pushing the VC, in the init methods of the VC, in the viewDidLoad and viewDidAppear but still the same behavior. I can't seem to get rid of this shift.
What's strange is that the back button disappears and reappears when pushing the new VC (using the default animation) but the 'Logout' button seems to stay in place and just shift to the right after the animation finishes. Also, the font on the buttons is not the default font but one of the system fonts (Helvetica light), may be related to this.
Any ideas on why this is happening?
I had the same problem. It is because of your rootviewcontroller not being set. Set the main page or the first page where your first navigation bar would be originating as rootviewcontroller. From there [self.navcontroller] pushviewcontroller...].
Try calling
self.navigationItem.rightBarButtonItem = yourUIBarButtonItem;
Also what is your logout button, is it the correct class? Perhaps a little more code?

Resources