Search code examples
iosobjective-ciphoneswiftswrevealviewcontroller

SWRevealViewController - RightViewController


I'm using SWRevealViewController for implementing two side navigation views in my application. I followed the story board method and successfully implemented the rear view and front view. I tried setting right view exactly like the rear view via storyboard, but couldn't do it.

I have set the reveal view controller segue to "sw_right" but it looks like it is not being recognized by - (void)prepareForSegue:(SWRevealViewControllerSegue *)segue sender:(id)sender which is called twice for "sw_rear" and "sw_front"

What Am I missing? enter image description here

- (void)prepareForSegue:(SWRevealViewControllerSegue *)segue sender:(id)sender
{
// $ using a custom segue we can get access to the storyboard-loaded rear/front view controllers
// the trick is to define segues of type SWRevealViewControllerSegue on the storyboard
// connecting the SWRevealViewController to the desired front/rear controllers,
// and setting the identifiers to "sw_rear" and "sw_front"

// $ these segues are invoked manually in the loadView method if a storyboard
// was used to instantiate the SWRevealViewController

// $ none of this would be necessary if Apple exposed "relationship" segues for container view controllers.

NSString *identifier = segue.identifier;
if ( [segue isKindOfClass:[SWRevealViewControllerSegue class]] && sender == nil )
{
    if ( [identifier isEqualToString:SWSegueRearIdentifier] )
    {
        segue.performBlock = ^(SWRevealViewControllerSegue* rvc_segue, UIViewController* svc, UIViewController* dvc)
        {
            [self _setRearViewController:dvc animated:NO];
        };
    }
    else if ( [identifier isEqualToString:SWSegueFrontIdentifier] )
    {
        segue.performBlock = ^(SWRevealViewControllerSegue* rvc_segue, UIViewController* svc, UIViewController* dvc)
        {
            [self _setFrontViewController:dvc animated:NO];

        };
    }
    //This is never executed even after setting the identifier
    else if ( [identifier isEqualToString:SWSegueRightIdentifier] ) 
    {
        segue.performBlock = ^(SWRevealViewControllerSegue* rvc_segue, UIViewController* svc, UIViewController* dvc)
        {
            [self _setRightViewController:dvc animated:NO];
        };
    }
  }
}

Solution

  • I figured out what the problem was. In loadStoryboardControllers method [self performSegueWithIdentifier:SWSegueRightIdentifier sender:nil]; was commented out. If we implement right view controller this has to be uncommented.