How to add a navigation bar to UITabBarController? - uitabbarcontroller

Im trying to add a navigation bar to all view controllers inside my tabbarcontroller. Do I add the nav bar to individual view controllers...
or
Is there another way?

Related

How to create a navigation stack of views in SwiftUI?

In UIKit it is possible to create a navigation view controller with a stack of UViewControllers.
let nav = UINavigationController()
nav.viewControllers = [vc1, vc2, vc3]
How would you achieve same in SwiftUI?
There are navigation buttons that push a view but there is no navigation controller

How to add a right button when specific UIViewController get loaded in Swift 3

I have two different UIStorboards and I am using a UINavigationController to load the pages.
I have a total of three UIViewControllers. Two of them are on the first UIStoryboard and the third one is on the second UIStoryboard.
1) Navigation controller
2) Main Controller
3) Value Screen Controller.
I want to add right button on navigation bar only when value screen controller get loaded. It should not be available on Main view controller.
I tried with this solution but not worked.
Each UIViewController has its own UINavigationItems. So you can just add this right button in your Value Screen Controller by adding this line:
self.navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: <#T##UIBarButtonSystemItem#>, target: <#T##Any?#>, action: <#T##Selector?#>)
You can place it in func viewDidLoad() if you want it to be place as soon as the UIViewController's view is loaded.

Navigation Bar Background Color Light with Swift 3

I add Navigation Bar in any view controller. But, I'm adding new CollectionView Controller in project. My problem is that I could not add Navigation Bar in Collection View Controller.
So I add Navigation Bar with code. I choose Top Bar- "Inferred" in Attributes Inspector. Here is the code.
//Add Navigation Bar
let height: CGFloat = 65
let navbar = UINavigationBar(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: height))
navbar.delegate = self
UINavigationBar.appearance().barTintColor = UIColor(red: 0.0/255.0, green:49.0/255.0, blue:79.0/255.0, alpha:0.1)
UINavigationBar.appearance().tintColor = UIColor.white
UINavigationBar.appearance().isTranslucent = true
UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName : UIColor.white]
But, the Navigation Bar Background Color in Collection View Controller is a little bit dark than other view controller.
In other view controller, I drag and put navigation bar.
- Navigation Bar style --> Black
- Translucent --> not enabled
- Bar Tint Color --> #00314F
I don't know why Navigation Bar Background Color in Collection View Controller is light than in Collection View Controller.
Please help me how to match Navigation Bar Background Color in all view controller.
If it is not easy to do, is there any ways to add Navigation Bar in CollectionViewController without embedded in Navigation Controller and without code.
It is beacause of the Translucent property of NavigationBar. It gives an effect where the image color looks faded as if a layer has been put on the bar, hence the color looks a little and different. Set off the translucent property of navigation bar as shown below. You can write this code in any lifecycle methods.
self.navigationController?.navigationBar.isTranslucent = false
It is because of translucent i think. When the navigation bar is not translucent, view can't locate behind the navigation bar to show what it has. But when is translucent, view stays behind the navigation bar and with view's color, you see it darker.

UITabBar item did select is not working

i have two tab bar items with two different table view with navigation controllers.
by clicking on the tab1--- table1 is opening...Good. but when i did select on table1 it goes to the another view (table did select view)....every thing is good.
but the problem here is
when i am clicking on tab2 ----table 2 is opening....Good.
But again clicking on tab1------ it is not loading the table1....it is loading (table did select view) view. As the last time i left it there.
i want to open table1----on clicking on tab1......by programming.
help me
That is the expected behaviour if you are using the tab bar controller and the navigation controller in the item of the tab bar. User will expect the tab to retain the state of the view.
If you still want to enforce the app to go back to the root view controller of the navigation controller when user goes back to the tab, you can implement the UITabBarControllerDelegate tabBarController:didSelectViewController: method. What this delegate method does is:
Tells the delegate that the user selected an item in the tab bar.
Then call the method of UINavigationController called popToRootViewControllerAnimated: when user tap on the tab. This will help you to:
Pops all the view controllers on the stack except the root view
controller and updates the display.
For example:
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
{
if(viewController == yourNavigationController) {
UINavigationController *navigationController = (UINavigationController *)viewController;
[navigationController popToRootViewControllerAnimated:NO];
}
}

Sencha Touch 2: Multiple instances of a NavigationView (one for each tab) : every panel pushed by controller opens in first tab

In my sencha touch app i have a NavigationView container which loads a panel view containing a list rendered from a store.
I have a tab-bar in which each tab opens this NavigationView container adding, depending on which tab is tapped, some extraparams in the store used by the panel view inside the NavigationView container.
This is working OK and for each tab i get the NavigationView container and inside it the panel view containing the right list for that tab.
The problem is these lists have some child lists that need to be loaded when tapping a list item. I do this using the following controller that pushes in the NavigationView container another view Panel containing the child list:
Ext.define('FirstApp.controller.Details', {
extend: 'Ext.app.Controller',
config: {
refs: {
// this is my NavigationView container
placesContainer:'placesContainer'
},
control: {
'placesContainer categorie list':{
itemtap: 'chooseCategory'
},
And my chooseCategory function is:
chooseCategory:function(list,index,target,record){
//these add some extra params to my store's proxy
Ext.getStore('Articoli').getProxy().setExtraParams({ catid: record.data.id });
Ext.getStore('Articoli').load();
this.getPlacesContainer().push({
// this is the target view panel
xtype:'articoli',
title:record.data.title,
data:record.data
})
}
And this works very well but when you click on a list item, its child list is pushed inside the first tab panel.
Example: i tap on the 3rd tab. The app shows the list corresponding to the 3rd tab. I tap on one of the list's items. The app loads its child list in 1st tab panel. I cannot see any changes until i tap on the first tab. There i can see loaded the child list of tab 3.
You can give onDisclosureItem:true to your list and in the controller give an disclose event so that on disclose it would load the sub categories and on item tap it would navigate you to the other view
'placesContainer categorie list':{
itemtap: 'chooseCategory',
disclose: 'openSubCategory'
},