let chatController = ChatLogController()
    chatController.user = user
    let nav: UINavigationController = UINavigationController(rootViewController: chatController)
    self.presentViewController(nav, animated: true, completion: nil)

上面的代码有效,我正在尝试将用户传递给下一个视图控制器,然后再进行演示
但是,这不起作用,它在下一个viewcontroller中为用户提供了nil:
    let chatController = ChatLogController()
    chatController.user = user
   let nav: UINavigationController = UINavigationController(rootViewController: MessagesController())
   // self.presentViewController(nav, animated: true, completion: nil)
    nav.pushViewController(chatController, animated: true)

我真的不知道为什么,对于这个愚蠢的问题,我很陌生。

最佳答案

如果我没看错,您的问题就是MessagesController()

试试这个:

let chatController = ChatLogController()
chatController.user = user
let nav: UINavigationController = UINavigationController(rootViewController: chatController)
// self.presentViewController(nav, animated: true, completion: nil)
nav.pushViewController(nav, animated: true)

10-06 03:56