Click here to Skip to main content
15,885,947 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Good day,

This may be a dumb question, but I only started with swift about 3 weeks ago. I am using SWRevealViewController to display a menu on my app. From this menu I am going to a certain view controller based on selection. From that selected view controller I would like to unwind back to the main view controller (Which is opened when launching the app).

How is it that the unwind method is reached, but nothing happens?

I must say that the unwind method is in an Objective-C class since the SWRevealViewController is written in objective-c and my app is written in Swift. I have bridging headers in place. Method is reached according to
Objective-C
printf("Unwind Method Called");
in the unwind method.

Any help would be greatly appreciated.

What I have tried:

I implemented the unwind methods and everything connected correctly in storyboard. I even added a line to print to the console under the unwind method and it prints. However, the view controller is not redirected to the first one.
Posted
Updated 21-Jan-17 1:53am

1 solution

In your case, I think your are not dismissing the view.

Can you show me the code, that how you are moving to second one from first.

Example : If using this

self.present(ViewController, animated: false, completion: nil)


then you need to add below code on back button or submit whatever for coming back.

dismiss(animated: false, completion: nil)


Hope this may help.
 
Share this answer
 
Comments
Christopher Smit 22-Jan-17 4:14am    
Thanks for the reply. I know those are the ways on how to do it, however I am using SWRevealViewController to display a menu and this controller has its own custom "push" segues and it does not seem to work well with hiding the view again, or I am not understanding it. I ended up calling the main view controller again as a modal view from the displayed view controller and this seems to be working fine. I will accept your answer however, as this should also be able to work.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900