以编程方式从UiView推送新的视图控制器

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

我试图在按下UiView内部的按钮后显示消息viewController。当我按下按钮时,消息viewController出现了,但是它缺少一些数据。我有一个单独的viewController,它可以推动控制器。我将在下面留下图片以显示我在说什么。

这是消息视图控制器的外观,代码到达那里的外观

 override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    dismiss(animated: true) {
        print("Dismiss completed")
        let user = self.user[indexPath.row]
        self.messagesController?.showChatControllerForUser(user)
    }
}

Image 1,

这是当我从UiView推送视图时发生的事情,这就是代码到达那里的样子。

        @objc func handleNewMessage() {
    let chatLogController = ChatLogController(collectionViewLayout: UICollectionViewFlowLayout())
           chatLogController.user = user

    let navVC = UINavigationController(rootViewController:chatLogController)
    self.window?.rootViewController?.present(navVC, animated: true, completion: nil)
}

image 2,

所有数据都推送通过,但是缺少后退按钮,并且不允许我实际发送消息。我正在使用两种不同的方法来访问同一控制器,并且期望看到相同的结果。我想知道是否有人可能会解决这个问题?

xcode uiview uiviewcontroller pushviewcontroller didselectrowatindexpath
1个回答
0
投票

[后退按钮不显示,因为您正在使用以下功能显示chatLogController

@objc func handleNewMessage() {
    let chatLogController = ChatLogController(collectionViewLayout: UICollectionViewFlowLayout())
           chatLogController.user = user

    let navVC = UINavigationController(rootViewController:chatLogController)
    self.window?.rootViewController?.present(navVC, animated: true, completion: nil)
}

如果从chatLogController推到messagesController,则在chatLogController上显示后退按钮。

© www.soinside.com 2019 - 2024. All rights reserved.