3

In the previous version of SWRevealViewController I was creating a segue of SWRevealViewControllerSegue class and in the prepareforSegue I used the following code.

#pragma mark - Navigation
- (void) prepareForSegue: (UIStoryboardSegue *) segue sender: (id) sender
{
    if ( [segue isKindOfClass: [SWRevealViewControllerSegue class]] )
    {
        SWRevealViewControllerSegue *swSegue = (SWRevealViewControllerSegue*) segue;
        swSegue.performBlock = ^(SWRevealViewControllerSegue* rvc_segue, UIViewController* svc, UIViewController* dvc) {
            UINavigationController* navController = (UINavigationController*)self.revealViewController.frontViewController;
            [navController setViewControllers: @[dvc] animated: NO ];

            [self.revealViewController setFrontViewPosition: FrontViewPositionLeft animated: YES];
        };

    }
}

In the new version of SWRevealViewController,there is no segue of SWRevealViewControllerSegue class.Instead there is a class called SWRevealViewControllerSetSegue .I created a segue of this class but the navigation is not happening.

The above code cannot be used in the new version as it is deprecated.What should I use in prepareforSegue?

What can I do to perform the navigation?PLease help.

abhimuralidharan
  • 5,752
  • 5
  • 46
  • 70
  • this is given at example purpose, but it not required one for SWLRevalViewCOntroller – Anbu.Karthik Sep 05 '15 at 06:36
  • you don't need it to do, just create a custom segue and set classes from SWRevealViewController. There is Two classes for use `SWRevealViewControllerSegueSetController` and `SWRevealViewControllerSeguePushController` and it works . cheers happy coding – Subhash Sharma Sep 05 '15 at 07:03
  • Then what is the difference between set controller and pushcontroller segue? – abhimuralidharan Sep 05 '15 at 08:48
  • i think this question is awesome and will try to make changes on what i have been trying. – Nischal Hada Sep 05 '15 at 09:09

4 Answers4

1

Try this code below

 UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    SWRevealViewController *revealVC = (SWRevealViewController *)[storyBoard instantiateViewControllerWithIdentifier:@"revealVCID"];
    [self presentViewController:revealVC animated:YES completion:nil];
Nischal Hada
  • 3,230
  • 3
  • 27
  • 57
1

You can use this one

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

    if([segue isKindOfClass:[SWRevealViewControllerSegueSetController class] ]){

        UIViewController *dvc = [segue destinationViewController];                
        UINavigationController *navCtrl = (UINavigationController *) self.revealViewController.frontViewController;        
        [navCtrl setViewControllers:@[dvc] animated:NO];        
        [self.revealViewController setFrontViewPosition:FrontViewPositionLeft animated:YES];

}
andr3s2
  • 238
  • 3
  • 10
0

This one works for me

UIStoryboard *sb;

if (IS_IPAD) {
    sb = [UIStoryboard storyboardWithName:@"iPad_Main" bundle:nil];
} else {
    sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
}


if ([segue isKindOfClass:[SWRevealViewControllerSegueSetController class]]) {

    UINavigationController* navController = (UINavigationController*)self.revealViewController.frontViewController;
    [navController setViewControllers: @[[sb instantiateViewControllerWithIdentifier:@"create"]] animated: NO ];
    [self.revealViewController setFrontViewPosition: FrontViewPositionLeft animated: YES];

}
Evana
  • 1,754
  • 13
  • 12
-1

Subhash Sharma's comment is correct.We don't have to code anything in prepareforSegue for navigation.

Just create a segue of type SWRevealViewControllerSeguePushController and perform this segue whenever needed.It simply works.

abhimuralidharan
  • 5,752
  • 5
  • 46
  • 70
  • My issue was that the segue was not working in the newer version.I created a segue of SWRevealViewControllerSetSegue class but the navigation was not happening.And I thought that there should be some code in the prepareforsegue method for this segue to work.But it was my mistake that I used SWRevealViewControllerSetSegue instead of SWRevealViewControllerSeguePushController.it solved my question. – abhimuralidharan Oct 07 '15 at 05:23
  • If you know the difference between set controller and pushcontroller ,please explain it here. – abhimuralidharan Oct 07 '15 at 05:25