1

I do not have storyboard enabled. I am initializing the viewcontroller like so:

var customViewController = CustomViewController();

then doing this says customViewController is nil:

self.navigationController!.pushViewController(customViewController, animated: true)
2
  • Do you call the tow lines of code together? Because, using CustomViewController() is ok to initialize a ViewController Commented Nov 11, 2015 at 2:20
  • create a nib file and use method initWithNibName:bundle: Commented Nov 11, 2015 at 2:37

1 Answer 1

3

I tried and succeeded

import Foundation
class MyCustomViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        self.view.backgroundColor = UIColor.redColor()
    }
}

and push

var customViewController = MyCustomViewController()
self.navigationController?.pushViewController(customViewController, animated: true)

have anything in your CustomViewController ?

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.