swrevealviewcontroller navigation item and bar button missing - ios

hello I have implemented SWRevealViewController in my swift app. The problem I am having is If I set SWRevealViewController as my initial ViewController all works fine. But If I launch this controller through code
let nav : UINavigationController = UINavigationController(rootViewController: self.storyboard!.instantiateViewControllerWithIdentifier("swrevealviewcontroller") as UIViewController)
self.navigationController?.presentViewController(nav, animated: true, completion: nil)
the navigation Title and barButtonIcon Disappears which is in my case is a hamburger menu icon.
SWRevealViewController is connected to the HomeViewController. and I am initiating SWRevealViewController when user clicks the login Button.
If you need more information regarding the storyboard screenshot let me know. I'll upload here.
Updated:
storyboard

navigation controller's navigation bar will only show up for view controllers that are contained by that navigation controller. Here, you're presenting a modal view. It's not contained by the navigation controller.
If you want the navigation bar to continue to appear:
If it's purely a matter of style, put a navigation bar on the modal scene you're presenting in the interface builder.
If you need to modally present a view that should be contained in a navigation controller, then you need to present a navigation controller--not a view controller.
Finally, if the view you're presenting is intended to be part of the navigation controller's navigation stack, then you need to present it with a push, not a modal segue.
Update
Do like simple ,
and call the perform segue as
[self performSegueWithIdentifier:#"main" sender:self];

I solved my problem by pointing Navigation Controller first and Tab Bar Controller second. Please, see the picture below.
Hope this help!..Thanks...

Related

How to keep NavigationController when performSegue from embeded tableviewcontroller

In the bottom left viewcontroller i have a searchbar at the top that call the tableview at the top , the problem is that i want to segue to the right viewcontroller with detail of it, but of course i'm losing my navigationController so when i'm into the right viewcontroller i can't go back anymore, how should i do to go back to my original Viewcontroller ?
Add Navigation Controller as the starting view in storyboard. And then Link RootViewController to it. This will ensure navigation bar in all the views coming next.
you may hide navigation bar in the view where not needed as
self.navigationController?.isNavigationBarHidden = true
push newViewController instead of presenting
Also please check, if you are presenting it modally. Modal segues take over the whole screen, so any navigation bars, tool bars, or tab bars that are in the presenting controller will be covered up. If you want a navigation bar on this modal controller, you'll need to add one specifically to it, and add any buttons you want to that new navigation bar (or tool bar). If you don't want to do this, then don't present it modally, do a push to it.

When I from a navigation controller( which is embed in a TabbarController) push to a new TabbarController, there is short than normal

When I push from a navigation controller (which is embed in a tabbar controller) to a new tabbar controller.
There is an issue here, the new tabbar controller is short than normal.
You can see the black rectangle under the tabbar of new tabbar controller.
And in the view hierarchy:
How to solve this issue here?
If can not, how to avoid this issue? I want from a tabbar controller push to a new tabbar controller.
If you created a storyboard item for TabBarController you wish to push to from navigation Controller, go to it and click on the checkbox Hide Bottom Bar On Push . This will hide the bottom tabBar of the parent TabBarController.
Do note that Apple does not recommend TabBarController to be rootViewController of Navigation Controller.

Navigation Bar not showing in embed Navigation Controller

I'm trying to display the navigation bar at the top of the screen, but it's not showing in embed navigation controller.
Here is how it is in the storyboard:
And here it's in the simulator:
As you can see, I created a custom TabBar (following this tutorial) at the bottom of the screen so I can navigate between the different views.
I believe that I'm going to have to load the navbar programatically because the only solution that I found was to set the navigation controller as the initial view controller, but I already set another view as the initial one so I can't do that.
Issue :
When you instantiate a viewController using storyBoard identifier they wont come with free embedded navigation controller, even if you have added a NavigationController to them. As a result you are adding a viewController without navigation bar to your tab bar VC.
Solutions:
Solution1: If you want each child viewControllers to carry their own navigation controller hence their own navigation stack, provide a storyboard identifier to Navigation Controller behind your child viewControllers and instantiate the Navigation controller itself rather than ViewController. And add NavigationController as you tab bar looking VC's child. Because navigation controller loads the embdedded VC by default you will see your child VC with nav bar.
Solution2: All that you care for is only nav bar than add the Navigation Controller behind the VC containing tab bar looking View.
Hope it helps
Have you tried constraining the navigation bar to your view? Otherwise it can move offscreen.
You need to point the tab bar controller segue to the navigation controller of your view - otherwise if you point the segue straight to the view you're just loading the view without any navigation controller attached.

How can I present a modal view on top of a tab bar controller?

I made one button on the navigation bar. I made it to modal view. But the problem is I can't bring this modal view on the top of the tab bar. What should I do?
In addition, I have used storyboard's segue to present the modal view.
Enter to see storyboard image
Enter to see simulator image
It's hard to tell from the screenshots, but it seems like what you want is for the tab bar to become greyed out just like the background of the view inside the UITabBarController?
Where are you presenting the modal view from? If view controller A is inside your tab bar controller, then presenting the modal view from A will result in the tab bar not getting grayed out. If you present from the tab bar controller, it should do what you want.
In the presenting view controller's code, instead of
present(modalViewController, animated: true, completion: completion)
try using
tabBarController?.present(modalViewController, animated: true, completion: completion)
(Where modalViewController and completion are whatever you mean to use for these arguments, of course.)
If you are using a segue to present the modal controller, then the same concept applies. Move the segue to the tab bar controller and then perform it on the tab bar controller from the presenting view controller.
tabBarController?.performSegue(withIdentifier: "yourSegueIdentifier", sender: tabBarController)
You can simply use the modalPresentationStyle of your view controller and set it to fullScreen or overFullScreen and this will automatically hide the tab bar, whether the view controller is presented from the tab bar or not.
Swift 4 example:
presentedVC.modalPresentationStyle = .overFullScreen
You can check the documentation for more information: UIModalPresentationStyle

iOS navigation with TabBarController and NavigationController

I have a RootViewController which is a TabBarController which have 5 ChildViewControllers. Each child is a NavigationController. Each child will be able present a FullScreenController which have modalTransitionStyle set to OverFullScreen and present by calling showDetailViewController. The FullScreenController need to be able to further navigate which will push another ViewController into the current NavigationController.
The problem I am facing is that the FullScreenController is presented by the TabBarController, and I cant present the original TabBarController again since it is the PresentingViewController of the FullScreenController.
Anyone know how to properly support a ViewController hierarchy with the following requirements
Should support a navigation bar and a tab bar
Should be able to present a FullScreenController which don't have navigation bar and tab bar
The FullScreenController can navigate to another ViewController which have both navigation bar and tab bar
Should support navigate backward
Each tab on the tab bar represent its own navigation stack
You can add full screen view as child controller to Each Tab bar controller and keep the close button from full screen view (close will take them back to tab bar view).
Hope this will help.

Resources