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

How to use it without storyboard? #59

Closed davamp closed 5 years ago

iDevelopper commented 5 years ago

With the init function:

    /**
     Instantiate a PBRevealViewController class programmatically

     - Parameters:
        - leftViewController:  A subclass of UIViewController (optional).
        - mainViewController:  A subclass of UIViewController (required).
        - rightViewController: A subclass of UIViewController (optional).

     - Returns:
        PBRevealViewController instance.
     */
    @objc public init(leftViewController: UIViewController?, mainViewController: UIViewController, rightViewController: UIViewController?)

Example: PBRevealIssue59.zip

davamp commented 5 years ago

Thank for answer my question.That's a great help

sfilo commented 5 years ago

For others interested, there is an example in the PBRevealViewController Example Project but I found you have to define Storyboard ID for the three views and also add main window initialisation and configuration to get it to work.

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; self.window.rootViewController = revealController; [self.window makeKeyAndVisible];