iosswiftcontrollerviewcontrollerunwind-segue

Swift skip login controller


so I'm new to swift and I'm having a little issue with skipping a controller if needed. This is how the storyboard is connected.

So basically I have the splash screen which will determine whether or not the login screen is necessary, originally I had it just like you can see in the image, splash goes to either login or home, but then a problem arised, in menu I want to logout and that'd would mean to make an unwind segue to Login BUT Login might've been skipped and was never created so it can't go back to it.

I've been trying to make it always go through Login and make a segue to home if login wasn't needed, this approach also had an issue, I couldn't make a segue before viewDidAppear and, well, it works... sort of, but it flashes the login screen before going to home which looks awful. Another thing that came to mind was to simply push the login controller on top but this is a nasty solution since the VCs will continue to stack and stack if the user logs in and out repeatedly.

is there any way to make this work?

Thanks in advance.


Solution

  • What about having your splash view go straight to your home view, and then menu view. If required, then present a login view modally over the home view.

    If you need to logout from the menu view, you can unwind to the home view, and trigger the modal login view again when the home view has loaded.