如何呈现UICollectionViewController?

问题描述 投票:0回答:1

我收到一个错误:

致命错误:在展开Optional值时意外发现nil

didTapUserScreenButton()工作正常,didTapChatControllerButton()给出了错误。我认为它可能会得到错误,因为didTapChatControllerButton()进入UiCollectionViewController?而另一个正常,因为它将进入UITableViewController?

func didTapChatControllerButton() {
    let chat_log_controller = ChatLogController
    let navController = UINavigationController(rootViewController: chat_log_controller!)
    present(navController, animated: true, completion: nil)

}


func didTapUserScreenButton() {
    let user_screen_vc = usersScreenVC()
    let navController = UINavigationController(rootViewController: user_screen_vc)
    present(navController, animated: true, completion: nil)
ios swift uinavigationcontroller
1个回答
0
投票

您错过了(当前为空)初始化参数持有者括号。尝试使用tris:

let chat_log_controller = ChatLogController()
let navController = UINavigationController(rootViewController: chat_log_controller)
present(navController, animated: true, completion: nil)
© www.soinside.com 2019 - 2024. All rights reserved.