Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unwind segue WITHOUT Storyboards using Swift

I can't seem to find a solution for this problem. All topics on unwind segues that I've found implement the segue via storyboards.

I am trying to learn how to make my layouts purely in code. So in my new Xcode projects, I am deleting the storyboard file.

I want to do an unwind segue on a view controller of mine that logs a user into the home screen of my app. When the user successfully logs in, the view should unwind.

Can anyone point me in the right direction on how to achieve this effect using only code?

like image 646
iOShepherd Avatar asked Mar 11 '23 20:03

iOShepherd


1 Answers

You can't do any "segue" action without segues which are storyboard items.

If the view you want to transition to is the first view on the navigation stack, you can use self.navigationController?.popToRootViewControllerAnimated(true)

If you just want to go to another view controller, you can use

presentViewController
like image 100
Michael Williams Avatar answered Mar 15 '23 13:03

Michael Williams