segue does not work in simple segue test - ios

I have a weird problem. I have created 2 viewcontrollers in my storyboard: testSegueViewcontroller and nextPageViewController.
The testSegueViewcontroller contains a UIButton NextPage. I Ctrl-dragged from this button to nextPageViewController and created a Push segue.
The problem is when i run this program and clicking on the NextButton in the testSegueViewcontroller it does not show the nextPageVieController :-(
Any ideas of what I'm doing wrong?

With this approach you should use modal segues. Push segue is a part of UINavigationController transitions
If you want to use push segue then you will need to put your testSegueViewcontroller into UINavigationController instance. This will allow the Push segue to work.

Push segue is a part of navigationcontroller if your viewcontroller is embed with uinavigation controller then only you will able to push the controller to another view. If you don't want to add navigation controller then use modal transitions.

You need to put the testSegueViewcontroller inside a UINavigationController.

Related

How to get rid of UINavigationController after doing a segue to a UITabBarController in Swift?

I basically want to "get rid" of the NavigationController I have set up for my login/registration NavigationController after the login/registration has been successful. Basically, I am doing a manual segue after executing some code that runs through an IBAction when the Login/Register button is pressed. My code runs just fine, but the thing is that whenever the segue executes, my second view controller, a TabBarController (which I want to somewhat make independent of the NavigationController) still has the navigation bar on top of the view (with the <Back button). I am doing the transition through a push segue, which kind of makes me realize that it is not the correct approach since it means I am nesting the TabBarController into the NavigationController itself. It's just that I do not know how to make it independent.
My approach is the following:
//...After various checks/functions, inside a function, I redirect myself to the TabBarController
self.performSegueWithIdentifier("redirectToMenuFromRegistration", sender: nil)
//Where the segue "redirectToMenuFromRegistration" is my TabBarController..
As I said, I do not want my TabBarController to be nested within my NavigationController, I want it to be somehow independent. Now another question. If I do this, will I still be able to pass data through ViewControllers?
Thank you so much for your help!
Cheers!
Set segue "Show" to "Present Modally" in storyboard.

What is Replace Segue in iOS?

I know how to do it but i need to know the details, internals. How is it different from modal segue?
replace segue from code
The differences is push segue needs a UINavigationController in order to perform.
A modal segue is not in a navigation stack they can only dismiss themseleves you do not pop view back to the previous controller like you do with a push segue.
A replace segue is only relevant on iPad or iPhone 6+. You can use replace segue to replace the contents of the master or detail pane of a UISplitViewController.

UITabbarController inside UISplitViewController

iam trying to make a UITbarbarController inside UISplitViewController
when making this segue modal it hides the MasterViewController ,when making it push Segue after reading apple Document we can't put UITabbarController inside UINavigationController,when i make the segue replace it doesn't animate and i cant dismiss the viewController anymore....
what is the best way to achieve this ?

Push segue from a view controller controlled by UITabBarController

Let's assume that a first view controller is connected with a UITabBarController and I want to make a push segue to the second view controller from this first view controller.
From my googling, it seems that a modal segue from a view controller connected with a UITabBarController hides the bottom tab bar, while a push segue doesn't.
However, my push segue is also hiding my tab bar in the second view controller. I have overridden prepareForSegue method in the first view controller.
Below are images of my storybard and the simulator. Anyone has an idea why this is the case? Thank you in advance for your helps.
Your trouble is because your tabViewController is embedded in the navigation stack that you initialise with your login screen.
you need to rearrange things so that each of your tab bar controller tabs opens to a new navigation stack.
What I suggest
your loginscreen should navigate to your tab bar controller with a modal/presenting segue, not a push segue. Remove the navController that encloses the loginscreen, you don't need it (well, even if you keep it, don't use a push segue, use a modal segue, and you won't then be referring back to that navController's viewController stack from inside your tab bar).
embed each of the first viewControllers in your tabViewCOntroller inside a separate navController.
Now you can push segue within your tabViewController's tabs.

NavController push from subview

I got an application with a tabbar and a navigation controller for one of the tab view.
The Navigation controller is pushing several views and one of them has a button which permits to add a subview (I am actually displaying a popup message -not an uialert- when pushing that button).
The problem is that I would like now to be able to push a new view controller once I pushed a button in the subview...
I cannot find my navcontroller, even when I use the pushmethod of appdelegate.tabbar.navigationController
Does one of you have easy idea about how to implement that ?
Thanks a lot !
If the button's press action of the second button is being handled in the same UIViewController as the other button's action you should simply be able to use
[self.navigationController pushViewController:newViewController animated:YES];.
If your subview has it's own UIViewController you could add a reference to your first UIViewController or to the navigationController itself and use it that way.

Resources