How to switch between different ViewControllers or NavigationController in Swift? - ios

I just got into Swift programming lately and I have an easy question I can't answer.
I understood that we start putting a ViewController to show something, then if I want to display another view I can use a segue linked to another view. But I don't like the fact that the view called by the segue doesn't take the full screen. It just looks like a pop-up screen.
So, how could I switch from a ViewController to another ViewController or NavigationController or whatever that keep the fullscreen view.
How could I change my view without passing through a segue and get the following view like a pop-up ?
Hope my wonder is clear enough to be answered :D
Thanks a lot to the community !!!

You can make your segue's presentation style as fullscreen. But if you want to use UINavigationController, first you need to embed your ViewController in UINavigationController(rootViewController: ViewController()). After that you can navigate to another ViewController using pushViewController method.
When you use UINavigationController, it will stack on top of each other. When you use popViewController, the current ViewController will be popped off from the stack. That's how works in general.

Related

Present a viewcontroller from a UITabbarController

Instagram has the following UITabbarController:
It has a special behavior which I couldn't duplicate. Every TabbarItem behaves like every other one but the center one doesn't show simply a viewcontroller but presents one instead. I would like to know how to do that.
I was thinking that they use a Toolbar with custom buttons but I feel like it's a bad practice. On every tab we have to allocate the view controllers. This behavior unfortunately resets the state of the view controller after a switch to another controller.
I would love to get a solution where I can use a UITabbarController but present one of the view controllers.

SplitviewController in navigationviewcontroller

Hey I am building my first ios application using xcode. I'm a total noob in xcode and swift and I am trying to use the storyboards to set-up my app. Here's a link to the prototype http://adobe.ly/1q5Imf6.
Basically my issue is where I want to do the split view on the resellers page. I want to use the splitviewcontroller only on the page, so after an intro viewcontroller in a navigation controller. like this
I read somewhere that a splitviewcontroller must be the initial view controller, however this works if I use segues that pop up modally. But when I do that I don't really have a navigation bar anymore on the page. I only have the splitview, but there must be the option to go back.
Am I doing this completely wrong or is there a simple fix to get what I want?
If you want to present your UISplitViewController modally, then you need to wrap into UINavigationController. After it you can add UIBarButtonItem in your UISplitViewController and set an action to dismissViewControllerAnimated(true, completion: nil)

How to do a real transition with iOS instead of modal?

From what I understand, modal is sort of like a pop up presentation of a view controller? So that means that the view controller that is calling presentViewController is still there?
What is the proper way of transitioning to another view controller without it just being a modal popup? (Meaning it is not a parent-child relationship between the two, I guess)
I think you want to use NavigationController to push other ViewController. Sorry if i have wrong answer
This is guide about NavigationController for you
http://www.raywenderlich.com/113388/storyboards-tutorial-in-ios-9-part-1

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.

ViewController to NavigationController and back

I have one problem for which im not sure how to solve. Currently i have main UIViewController with some buttons. This is the initial view that is created with app. On it, one button calls storyboards segue with style Modal on ViewController which is part of UINavigationController. After that few other viewcontrollers are handled within the UINavigationController via segues and getting back via navigationController:popViewControllerAnimated. What i dont know is how to get back from UINavigationController to first UIViewController. I tried, when I'm on first one on navigationctrl,
[self removeFromParentViewController];
yet that only removes the view but it seems that UINavigationController somehow stays alive as result is black screen. Creating unconnected segue and call it from code would be possibility, but im not sure if that is the proper way. Would that leave navigation controller alive ?
Is there any reason you are using a UIViewController first and THEN a UINavigationController?
Why not change this so that the UINavigationController is the initial view controller and then drive everything from there.
If you want the first view to not have a nav bar then you can hide it easily.
That way you can move around through all views by popping and pushing through the UINavigationController.

Resources