I am new to Swift and want to make a simple application
When the user launch the application, He sees the FirstViewController
where there is 1 Login button, when the user tap on this button, application present a SecondViewController
modally
On the SecondViewController
there are text fields and an "Auth button", I want that by tapping on the "Auth Button", the SecondViewController
dismissed and the FirstViewController
shows the ThirdViewController
ok, I using self.navigationController.show() method
let secondVC = SecondViewController()
self.navigationController.show(secondVC, sender: self)
and dismiss method for dismiss VC, BUT when I try open ThirdViewController after dismiss
, its doesn't work
func buttonTapped() {
let firstVC = FirstViewController()
let thirdVC = ThirdViewController()
firstVC.navigationController.show(thirdVC, sender: self)
self.dismiss(animated: true, completion: nil)
}
How to do it right?
I do not use storyboard, if it's important
You are "new to Swift" ... you may want to spend more time learning the basics before trying to "make a simple application".
The problem is that, at this point, you don't even know what to ask, or proper terminology.
For example, you say:
SecondViewController
closes and theFirstViewController
opens theThirdViewController
" ... "close" and "open" are ambiguous termsI don't mean to sound harsh, but would you try to write a novel before learning the alphabet?
However, here is a quick, very simple example...
We start with
FirstViewController
as the root controller... button tap presentsSecondViewController
and sets a closure... button tap in that controller calls the closure, at which point we pass the user entered strings and replace the root controller withThirdViewController
: