iosobjective-cuiviewcontrollerswrevealviewcontroller

How to use pushFrontViewController with SWRevealViewController


I am using the SWRevealViewController library. Using an AppCoda tutorial (also excellent), I've managed to get this working well. However, I have now configured a 'settings' screen where I want to save the content into Core Data and then pop the screen back to the home screen.

Because the settings screen has an embedded navigation bar and iOS 7 doesn't allow a navigation bar within a navigation bar, then, I am using a workaround to call it.

// Get the view controller
UIViewController *vcNew = [[UIStoryboard storyboardWithName:@"Main" bundle:NULL] instantiateViewControllerWithIdentifier:vcName];


// Swap out the Front view controller and display
[self.revealViewController setFrontViewController:vcNew];
[self.revealViewController setFrontViewPosition: FrontViewPositionLeft animated: YES];

What I don't know how to do now, is how to pop this.

The standard: [self.navigationController popViewControllerAnimated:YES]; and [self dismissViewControllerAnimated:YES completion:nil];

don't seem to work at all.

I note from John Lluch's documentation that it's now necessary to use 'pushFrontViewController'. However, I am no clearer on how to do this.

I assume I use something like this:

[self.revealViewController pushFrontViewController:<(UIViewController *)> animated:<(BOOL)>]

But what is the identity of the UIViewController?


Solution

  • The clue was of course in the question I asked:

    I simply used the identifier of the sw_rear viewcontroller and executed the following.

    // Get the view controller
    UIViewController *vcNew = [[UIStoryboard storyboardWithName:@"Main" bundle:NULL] instantiateViewControllerWithIdentifier:@"SW_FRONT_ID_GOES_HERE!!!"];
    
    // Swap out the Front view controller and display
    [self.revealViewController setFrontViewController:vcNew];
    [self.revealViewController setFrontViewPosition: FrontViewPositionLeft animated: YES];
    

    Easy...