SWRevealViewController
SWRevealViewController copied to clipboard
Problem re-showing UISplitViewController
I have a MasterDetail storyboard setup as created by the Xcode 7 project template, using a UISplitViewController as front view controller (and additional setup in AppDelegate application didFinishLaunching) as described in https://github.com/John-Lluch/SWRevealViewController/issues/518 .

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
self.window.backgroundColor = [UIColor whiteColor];
UIStoryboard *mainSB = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];
UISplitViewController *splitVC = (UISplitViewController *) [mainSB instantiateViewControllerWithIdentifier:@"SplitVC"];
splitVC.delegate = self;
MasterViewController *masterVC = (MasterViewController *) [mainSB instantiateViewControllerWithIdentifier:@"MasterVC"];
UINavigationController *masterNav = [[UINavigationController alloc] initWithRootViewController:masterVC];
DetailViewController *detailVC = (DetailViewController *) [mainSB instantiateViewControllerWithIdentifier:@"DetailVC"];
UINavigationController *detailNav = [[UINavigationController alloc] initWithRootViewController:detailVC];
splitVC.viewControllers = @[masterNav, detailNav];
// SWRevealViewController
UINavigationController *navController = (UINavigationController *) splitVC.viewControllers[splitVC.viewControllers.count-1];
navController.topViewController.navigationItem.leftBarButtonItem = splitVC.displayModeButtonItem;
splitVC.delegate = self;
SWRevealViewController *swRevealVC = [mainSB instantiateViewControllerWithIdentifier:@"SWRevealVC"];
MenuTableViewController *menuVC = [mainSB instantiateViewControllerWithIdentifier:@"MenuVC"];
[swRevealVC setFrontViewController:splitVC animated:YES];
[swRevealVC setRearViewController:menuVC animated:YES];
self.window.rootViewController = swRevealVC;
[self.window makeKeyAndVisible];
After app launch, the SplitViewController shows the MasterViewController, I can select an item and show the DetailViewController - so far so good.
But when I open the menu, select a menu item to show a different UIViewController (via SWRevealViewControllerSeguePushController segue type), and then want to show the UISplitViewController again (also via SWRevealViewControllerSeguePushController), the Detail ViewController is shown, instead of the MasterViewController.
Do I have to setup something in code before the segue is performed (like in AppDelegate)?
I do not see the point of having a split view controller with SWRevealViewController
It's the Xcode default for universal Master-Detail-apps (no need for handling iPad and iPhones differently)
Hi @thomers 1- I think you don't need to have a connection (segue) between the rear view and the UISplitView 2- Why are you using SWRevealViewControllerSegue all over your project. It should be used for rear and front views. That's it.
It is not mandatory to use this default storyboard
Thanks @Souf-R
- Hmm, but how do I show the split VC from the menu, if the user is shown a different view controller? What do I call in tableView:didSelectRowAtIndexPath: to show the split VC again?
- Have a look at the "official" RevealControllerStoryboardExample2 - the setup is similar there:
@iDevelopper Of course it's not mandatory - but how do you implement the automatic Master/Detail-split on iPads then?
aaaah ok, I think your problem now is just with the portrait mode when using iPad. If so, I have the same issue then I disabled the portrait mode my app now is working in landscape mode only when using iPad
@Souf-R Actually yes, I have the problem with iPad portrait mode also - but this is not the same problem I described here, since this one happens on iPhones and iPads, regardless of orientation.
It seems my only option is to remove the UISplitViewController, create 2 separate storyboards (iPhone, iPad) and use the SWRevealViewController as in the RevealControllerStoryboardExample2. (?)
If somebody could explain why use UISplitViewController with SWRevealViewController as SW is designed to replace UISplitViewController?
@iDevelopper The way I understood it - SWRevealViewController can only show one UIViewController as "front".
If you take 1 min to create a new Xcode project based on the "MasterDetail" template, and run it on iPad simulator, you see that both the Master and the DetailViewController can be visible at the same time, using the bigger available screen estate on iPad better (but giving the user the option to hide the MasterVC, if he wishes). On iPhone, only the MasterVC or the DetailVC is shown at one point in time.
All this is done automatically, with only one storyboard, by using the UISplitViewController.
If you can tell me how I can achieve the same (showing MasterVC and DetailVC at the same time on iPad, with MasterVC hideable) using SWRevealViewController, I will be more than happy.
Ok I'm watching!
Thanks, but no - in your project, the Master controller is the menu. What I need is the master controller as list (segueing to the detail controller) AND a menu controller, with the master controller as one of the view controllers that can be chosen from the menu. You see the structure in the image in my first post.
Anyway, I chose to ditch the SWR for my prototype and use a tab bar as "pseudo-menu" instead. Uglier, but works as universal storyboard out of the box!
Thanks for your work!
In fact you want two SWRevealViewController?
@thomers I know this is an old thread but did you ever come back to this and get the split view working with SWRevealViewController's menu?