Open xavistas opened 9 years ago
I am struggling with this same issue, if anyone might know the answer?
I've tried something along the lines of:
let navigationController = self.window?.rootViewController as! SWRevealViewController;
let viewController = navigationController.storyboard?.instantiateViewControllerWithIdentifier("ImportFileSelect") as! ImportFileSelect
navigationController.showViewController(viewController, sender: self)
This does not work though.
There's a few references to code being put in prepare for segue, but this has deprecated code in it:
See http://stackoverflow.com/questions/24676774/prepareforsegue-in-swrevealviewcontroller-with-swift as an example.
perform block no longer exists.
Release notes state:
"- Took a cleaner approach to storyboard support. SWRevealViewControllerSegue is now deprecated and you should use SWRevealViewControllerSegueSetController and SWRevealViewControllerSeguePushController instead."
But, there is no example of how to use these new methods.
Thanks for your help anyone.
same problem here.
This might help. I kinda answered my own question here:
I'm not sure if this works when it's an item on the menu.
@tholder Thank you for the reply. It fails when the target view controller is one of the viewcontroller from menu items. It's failing in the third line. (self.revealViewController is nil)
var rvc:SWRevealViewController = self.revealViewController() as SWRevealViewController
Could you have a look and suggest any solution if might have come across.
(My problem to be precise I have a second level of view that goes from one of the menu item controllers as shown in the below storyboard. First level of controllers works perfectly. Segue connecting the menu to views is SWRevealViewControllerSeguePushController. For second level segue is show (push). When coming back from the second level to menu item view it fails. I came across that we need to do some preparation when coming back to menu controller in prepareforsegue method.)
Hmmm... I'm not entirely sure I can, this totally confuses me and no one seems to have the definitive code for doing this with the latest code, either in swift or otherwise. Somewhat surprised as this seems like an obvious thing to want to do. I have to revert to using a static menu. I'll have another play with it when I get a moment, but my knowledge is pretty weak at the moment.
@tholder I went ahead with your code and found a solution to my problem. If anyone who is looking for the solution I'm listing the steps below that worked for the above scenario (refer above picture).
Two things I did to make it work
self.revealViewController() as SWRevealViewController to self.parentViewController! as! SWRevealViewController
from tholder's code. Thanks a lot for the above approach. It solved my problem :)
Great! Any chance of throwing together a open source public repo with the exact code in? I'm sure there are dozens of other people that will benefit from it.
I'm actually planning on creating a bootstrap iOS app for beginners in near future . For now I'll answer the SO question with a link to this issue. Hope that helps others
Dose anyone has an example of creating segue yet ?
this is what worked for me
` let storyboard = UIStoryboard(name: "Main", bundle: nil)
let sw = storyboard.instantiateViewControllerWithIdentifier("SWRevealViewController") as! SWRevealViewController
self.view.window?.rootViewController = sw
let destinationController = self.storyboard?.instantiateViewControllerWithIdentifier("StoryboardID") as! NameOfViewController
let navigationController = UINavigationController(rootViewController: destinationController)
sw.pushFrontViewController(navigationController, animated: true) `
How to make a segue in code in swift to perform a segue to come back from a button to the menu please?