I know this is probably an easy task but I can't get my head around how to solve it. I'm not using a NavigationController
by the way. Basically I have 3 view controllers in my app:
- -
LoginVC
(this has a register button. when tapped, it goes to the SignupVC) - -
SignupVC
(if user signs up, it will push to the MainAppVC) - -
MainAppVC
(has a logout button)
For the transitions, I use the method: present(viewController, animated:, completion:)
When the user logs in via the LoginVC, he'll be presented the MainAppVC as expected. When he logs out, I'll dismiss
the current VC (which is the MainAppVC) to send him back to the LoginVC
.
Now here is the case where I have questions about. When the user does not have an account and signs up, this is the VCs he will pass through (LoginVC > SignupVC > MainAppVC). Once he registers successfully, he'll be presented the MainAppVC. Now once he logs out, he'll be transitioned from the MainAppVC to the SignupVC because I used the same dismiss
method.
What I want to do is to send the user back to the LoginVC from the MainAppVC. How do I accomplish that without using a navigation controller in my project? How do popular apps (Facebook, Twitter, Instagram, etc) handle this in their apps?
One way I can think of is to perform a segue from 3rd to 1st VC but I think that's a dirty way since it just adds to the stack, instead of popping it off which is a potential issue.