Why is my UIViewController's view nil?

时间:2016-07-11 22:41:35

标签: ios uiviewcontroller

I'm new to presenting UIViewcontrollers programmatically, and I'm having some issues presenting its view. Here is my code:

override func willBecomeActive(with conversation: MSConversation) {
    let controller = instantiateUserStickersController()
    self.addChildViewController(controller)
    self.view.addSubview(controller.view) //This line throws the error
}
private func instantiateUserStickersController() -> UIViewController {
    guard let controller = storyboard?.instantiateViewController(withIdentifier: "UserStickersViewController") as? UserStickersViewController else { fatalError("Unable to instantiate a UserStickersViewController from the storyboard") }

    return controller
}

Why can't I access the controller's view? I'm sure I set the storyboard ID correctly

Here's my storyboard:

Here's my storyboard if that helps

0 个答案:

没有答案