iDevelopper / PBRevealViewController

A UIViewController subclass for revealing a left and/or right view controller above or below a main view controller.
MIT License
80 stars 16 forks source link

Programmatically set controllers not working #24

Closed valeIT closed 7 years ago

valeIT commented 7 years ago

If I use storyboards everything works, if I instantiate it programmatically the controllers .revealViewController() is always nil and because of that it doesn't show the side controllers at all. Do I need to call something else after instantiation?

Repro:

1.

Modify the Swift3 Example, at the bottom of "AppDelegate.swift" add these lines just before "return true":

let vc = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "MainNC1") guard let finalVcLoggedIn = PBRevealViewController(leftViewController: UIViewController(), mainViewController: vc, rightViewController: UIViewController()) else { fatalError() } self.window?.rootViewController = finalVcLoggedIn self.window?.makeKeyAndVisible()

2.

Go to the "Main.storyboard" file and change the main navigation controller identifier to "MainNC1".

Edit: The rest works correctly, if I save and instance of PBRevealViewController I can show and hide the side controllers, it's just the .revealViewController() that doesn't work.

iDevelopper commented 7 years ago

I have no problem with that:

PBRevealProgramExample.zip

valeIT commented 7 years ago

Thanks, it works. My mistake.

iDevelopper commented 7 years ago

Welcome!

iDevelopper commented 7 years ago

For other users, it could be great to know what was your mistake.