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

Black screen when starting #63

Closed ccannell closed 5 years ago

ccannell commented 5 years ago

I'm having an issue getting setup. I'm using Swift 4.2, programmatically creating UI, and separating the UIViewController and UIView into separate files. I started from the example you provided in a zip on issue #59. The example works fine as written, however, if I change MainViewController.swift to the following:

import UIKit

class MainViewController: UIViewController {

    override func loadView() {
        view = MainView()
    }
}

and create MainView.swift with the following:

import UIKit

class MainView: UIView {

    override init(frame: CGRect) {
        super.init(frame: frame)
        setupView()
    }

    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        setupView()
    }

    func setupView() {
        self.backgroundColor = .white
    }
}

I do not see a white background. I get a black background. I have separated the UIView and UIViewController in other projects successfully but it doesn't appear to play with with PBRevealViewController. Any help would be appreciated. Thanks.

iDevelopper commented 5 years ago

It seems that your view has a frame equal to zero.

Try

        view = MainView(frame: UIScreen.main.bounds)
ccannell commented 5 years ago

That did it. Thank you very much!