0

I want to auto launch on my SWRevealViewController view after I've reach my view.

For exemple, I'm on my SWRevealViewController and I go on an another view. If I want to go back, I want to go on my previous state : SWRevealViewController in rear view.

When I've tried, I've made this :

if (myPreviousVC == "editProfile")
{
     UIApplication.sharedApplication().sendAction(menuButton.action, to: menuButton.target, from: self, forEvent: nil)
}

This code just push my menuButton that launch my SWRevealViewController.

But I don't like this way, I want to know if there is a way to just launch my SWRevealViewController when I've reach the front view.

Michal
  • 162
  • 1
  • 14

2 Answers2

0

You have to use the segues sw_front and sw_rear in your storyboard. To do that :

  1. Add a UIViewController in your storyboard as SWRevealViewController.

  2. Add a custom segue to your menu controller as sw_rear and as SWRevealViewControllerSetSegue

  3. Link your first ViewController as sw_front also as SWRevealViewControllerSetSegue

With this it will work for this first view.

If you want that all your views have the menu as SWRevealViewController, you have to use UINavigationControllers (in your storyboard if you want) and then link the segue from you menu controller as a SWRevealViewControllerPushSegue and with no identifier to the correspondingUINavigationController.

Antoine
  • 1,139
  • 9
  • 21
  • You didn't ask the question. My SWRevealViewController works fine, I just want to know how trigger it with code. – Michal Aug 19 '15 at 11:54
0

I found my answer.

It was :

if (myVariable == "stuff")
    {
        self.revealViewController().revealToggleAnimated(true)
        self.revealViewController().setFrontViewController(self, animated: true)
    }

Can somebody put that answer in "accepted" ?

Michal
  • 162
  • 1
  • 14