iOS: Navigation Bar not showing up on manual segue - ios

I have the following setup
-> Navigation Controller -> View Controller A -> View Controller B
B has some left and right navigation items which show up in this sequence
I have another flow where
-> Navigation Controller -> View Controller A -> View Controller C -> View Controller B
In ViewController C, when a save button is sliced, I manually trigger the segue to show View B. But, in this scenario, the navigation bar does not show up.
If I embed controller B in a navigation controller, then in the prepareFor Segue of Controller C, I cannot refer this as the destination. How do I fix this?
I am putting in some screen shots of the settings below:
This is the nav bar in A
The segue from A->B. This is triggered by selecting a row in a table View
This is how the nav bar in B looks when triggered from A
The segue from A->C
This is the nav bar in C
The segue from C->B
From C to B, I am triggering the segue as below:
dispatch_async(dispatch_get_main_queue(), {
self.performSegueWithIdentifier("SegueGroupView", sender: self)
})
On this trigger, the nav bar in B is not appearing

Related

Issue in presenting view controller after pushing another view controller

I have three view controllers -> A, B, C; A being the initial view controller.
Due to some requirement, i am pushing B view contoller over A view contoller.
After some processing, I am also presenting C view contoller over A view controller.
But if i am going to B in the time the processing happens, C view controller is presenting on B view controller.
Instead, i want when i go back from B, then C should be visible over A view controller.
I am doing the presentation and pushing programatically.
I tried to present C view controller over A ->
let navVC = UINavigationController(rootViewController: C)
navVC.modalPresentationStyle = .overFullScreen
A.present(C, animated: true, completion: nil)
i want C to present on A only, instead it is getting presented over B.
You have to pop() your B controller, and only then present() your C controller

Open two controller A & B on one tab item in swift

I have a problem, I want to open two view Controllers on single tab from to different way.
Like:
Login Screen --> Home Screen --> On home screen two button A & B
1 When click on the button A, open A controller on tab controller tab1
2 When click on the button B, open B controller on tab controller tab1
I have 5 tab in tab controller.
Please help me for that issue.
Please refer attached screen for more help.
Thanks,
you can replace ViewController By using this
func tabBarController(tabBarController: UITabBarController, didSelectViewController viewController: UIViewController) -> Bool {
let selectIndex : NSInteger = (tabBarController.viewControllers?.index(of: viewController))!
if (selectIndex == 1) {
let vc = UIViewController() // your new Controller
var allviews = tabBarController.viewControllers
allviews?.remove(at: selectIndex)
allviews?.insert(vc, at: selectIndex)
tabBarController.setViewControllers(allviews, animated: true)
return false;
}
return true;
}
(Please add some more information to your question, or at least code to know what have you tried.)
By your question, It seems you need a Tab Bar Controller.
You use tab bar controller to organize your app into one or more distinct modes of operation. The view hierarchy of a tab bar controller is self contained. It is composed of views that the tab bar controller manages directly and views that are managed by content view controllers you provide. Each content view controller manages a distinct view hierarchy, and the tab bar controller coordinates the navigation between the view hierarchies.

Presenting view controller with overCurrentContext then pushing to navigation stack results in navigation bar underlapping

I'm hitting my head against the wall with a navBar issue. See this sample project for a better idea of what I'm trying to achieve. Basically, my app structure is like this:
NavController -root-> ViewControllerA -> button -> push -> ViewControllerB --> ViewControllerC
| |
button -> presentModally |
| |
V |
PopoverViewController |
| |
button -> push to the nav controller |
| |
| |
---------------------------------------
A button on the second view controller (call it B) of the nav stack will present a modal view controller with a clear background (its modal presentation style is overCurrentContext to look like a popover):
Then, a button on the popover will push a new view controller on to the nav stack (call it C):
[
The popover is presented by B as opposed to the actual nav controller (B defines the presentation context). This so that when the popover pushes C on the stack, C doesn't just cover B, but covers the popover as well.
The problem arises when dismissing C. The nav stack pops back to B with the popover still on top (which is my intention). However, B now fills the entire frame of the nav view controller (before C was pushed, B's top was pinned to the navBar). This causes views near the top of B to be clipped by the navBar:
A look at the UI Inspector confirms that this is because B's view now fills the nav controller's view:
This was not the case before C was presented. Any ideas as to what's causing this to happen?
You are manually pushing a view controller onto the stack which doesn't have a navigation controller. A better way to do it would be to segue from view controller B to view controller C using a segue identifier. Once you setup the segue in the storyboard you will see that view controller C gets a nav bar automatically. You might want to use a delegate method from the popover view controller to B to trigger the segue.
I had a problem very similar to this one. I was presenting a view controller using a .overCurrentContext presentation mode. When the viewController was displayed the navigation was over it!
To solve the problem I just asked to the navigation show the new view controller instead of the old viewController.
viewController.navigationController?.present(navigationController, animated: true, completion: nil)
Doing by this way the viewController will not be behind the navigation anymore. I hope it helps someone.
swift 5
I did this way:
let vc = viewControllerToDisplay()
let navVc = UINavigationController(rootViewController: vc)
navVc.modalPresentationStyle = .overCurrentContext
navVc.modalTransitionStyle = .crossDissolve
navigationController?.present(navVc, animated: true, completion: nil)

Tab bar - more menu table view, navigation class doesn't call

Hierarchy of my Storyboard is:
-- Nav Controller -> First Controller
/-- Nav Controller2 -> Second Controller
/--- Nav Controller3 -> Third Controller
/---- Nav Controller4 -> Fourth Controller
HomeScreen ---> TabBarController ----- Nav Controller5 -> Fifth Controller
\---- Nav Controller6 -> Sixth Controller
The problem is: Navigation to Nav Controller6 is located on More table view. Nav Controller 6 has its own custom class extend from NavigationController. It has some methods like "viewDidLoad", "viewWillAppear" and so on. But it doesn't call from more table view.
The view redirects correctly, and navigation works fine but methods are not get called.
What should I look for? What I'm doing wrong?

How to unwind from UITabBarController to custom view

I´ve a UITabBarController in the middle of a storyboard and I want that when I push back button on UITabBarController (TabBar) sends me to View02 directly.
My sequence is:
NavigationController->UIViewController01-> UIViewController02 -> UIViewController03 -> UITabBarController -> 3 TabBarViews
Could you help me, please?
Thanks in advance,
You have to create an unwind segue. First add a method in the view controller you want to unwind to:
- (IBAction)unwindToMyViewController:(UIStoryboardSegue *)unwindSegue
{
}
Then in a view controller you want unwind from drag from the button to the green exit icon and select your action.

Resources