0
votes

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?

3

3 Answers

4
votes

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...

1
votes

I don't know the SWRevealController library, but a generic way to place a new view controller on top is just to present it...

*vcNew = [[UIStoryboard storyboardWithName:@"Main" bundle:NULL] instantiateViewControllerWithIdentifier:vcName];
// btw, if you're inside another view controller from the same storyboard, you can
// use self.storyboard instead of the longer 'storyboardWithName'
[self presentViewController:vcNew animated:YES completion:^{
    // this block runs when the present animation completes
    // you can usually do nothing in here
}];

If that doesn't work for some reason, try presenting it on your SWReveal library container, like this (I doubt you'll need to do this)...

[self.revealViewController presentViewController:vcNew // ... and so on

If you keep a pointer to it, you can dismiss it from the same view controller that presented it, otherwise, it's usually easier to not keep the pointer and have settings vc dismiss itself when it's done...

// in SettingsViewController.m
// when it's time to dismiss
[self dismissViewControllerAnimated:YES completion:^{}];

Also, just rereading your post, my guess on what view controller should be used in the docs pushFrontViewController would be the one you want in front, which is vcNew

0
votes

Popview is the view where you want to navigate.As per your question at the place of (UIViewController *), viewcontroller's object will place.

Like this:

MainVC *mv = [[MainVC alloc]init];
    UINavigationController *mnav = [[UINavigationController alloc]initWithRootViewController:mv];
    [reveaself.revealViewController pushFrontViewController:mnav animated:YES];

By this you can navigate like the pop.