Tab bar controller inside a uinavigationcontroller - ios

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

Related

Navigate from a navigation bar view controller to a tab bar view controller

What is wrong with this approach? There is no coding behind it. But, I cannot see the item nor the title of the last scene on the right (as their titles are set to "cannot see").
Even if I add a back button, and set it's title to something, it keeps showing the default back button.
The storyboard
You are pushing UITabBarViewController instance in to UINavigationViewController stack. In such case navigation bar is managed by UINavigationController that is way you don't see "Cannot see" UIBarButtonItem in the nav bar.
UITabBarViewController works best if it is the rootViewController of the application. Take a look at this unswear to see how UITabBarViewController should be used.

How to hide the left side navigation bar title

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

iOS Swift: Incorrect Navigation Bar Appearing

The incorrect navigation bar is appearing on my Table View Controller screen (see Storyboard Below).
I would like what's displayed on the storyboard to be my navigation bar (i.e. with "Main Feed" title and Sign Out button on the top right). However, this is what I'm actually getting -
There are two issues here: 1) The incorrect navigation bar is displaying (this one has a login back button); 2) the first few table view cells are placed underneath the nav bar vs. under it.
This happened after I embedded the Table View controller in the Tab Bar Controller. I want a bottom tab bar in the main portion of my application hence the reason why I added the Tab Bar Controller. Any suggestions on how to fix this? Rather than using the Tab Bar Controller in storyboard, is there a way to do this programatically? Thanks!
The navigation bar that you are seeing on top of the stack is the navigation bar from the UITabBarController itself, that is why you are seeing the back button show "login". There's a few ways to work around this, programmatically:
When you initialize the UITabBarController, set it's navigationController's navigation bar property to "hidden"
Go through each view controller form the beginning of your app up to where you first see this problem and in the "init" method of the viewController you are testing, set the navigationbar to hidden. Something like, self.navigationController?.navigationBar.hidden = true;
This is how you can "debug" this issue, but it's going to take some tweaking to get it right.

UIBarButton unclickable in empty ViewControllers

i've created a tabBarController subclass and linked 3 viewcontrollers to the TabBarController in the storyboard. In the 3 ViewControllers which is directly connected with the tabBarController the UIBarButtons wont react when i click. They wont show the log message and does not do the highlight color. It seems like the navigationBar interaction is disabled or something. When i present a view modally on top of one of the 3 ViewControllers i have no problem with interaction with a UIBarButton in the modally presented View. I'm wondering what could result in such? i've struggled with this for ours.
i don't know if this has anything to do with it aswell, but in the modally presented views this does also result in white statusBar textColor, but it does not change it in the 3 views connected to the TabBarController.
What could this issue be?
self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
self.navigationController.navigationBar.translucent = NO;
i've simply manually added a UIBarButton in the storyboard and then connected this action.
-(IBAction)testAction :(id)sender {
NSLog(#"test");
}
Try this
You just take 3 Navigation Controller as your tab bar view controller rather than simply view controller.
And connect tab bar view controller with navigation controller.
On navigation controller there is one view controller, on that navigation bar put your bar button item and connect to IBAction Method.
Its works for me.

Navigation bar button unresponsive in child view controller of UITabBarController

I instantiate my UITabBarController by calling navigationController.viewControllers = #[[self.storyboard instantiateViewControllerWithIdentifier:#"tabController"]];
My Tab bar controller has a child view that is embedded in a navigation controller. However the bar button (item) is unresponsive when I touch them (the buttons in the navigation bar). I have tried logging the action but it appears as if the button is not firing at all.
The only thing that I have done differently is the way i instantiated the tab bar controller. Am I missing something?
I connected the navigation bar button from the storyboard to an action so it is hooked up successfully. Please note there is also a navigation Controller pointing to the UITabbarController not shown below.
The unwanted behaviour maybe because this flow (navigation controller to tabbar controller) is ill advised in the Apple HIG. More information can be found here: Storyboard with NavigationController and TabController. The solution I found was to hide the navigation bar on the navigation controller that links to the navigation bar (can be done in interface builder), then make it reappear in the new navigation controller that the tab bar links to. Confusing I know, I can help anyone who ever has a similar issue.
Is there any specific reason you are doing this:
navigationController.viewControllers = #[[self.storyboard instantiateViewControllerWithIdentifier:#"tabController"]];
You can simply drag an outlet from the UITableViewController to the UINavigationController using only the Storyboard.
I think you forgot to add the navigationItem. In the storyboard, add a navigation Item to your viewController and move your bar button items to the navigation bar that appears on the top.

Resources