gpt4 book ai didi

ios - 检测哪个 viewController 呈现了 SideMenu 并为其呈现实现适当的功能

转载 作者:行者123 更新时间:2023-11-29 06:00:14 25 4
gpt4 key购买 nike

我正在使用the following pod用于我的 SideMenu 功能。现在,如果我从 XYZ viewController 打开它并选择再次打开 XYZ viewController 的行,则页面将被推送,但相反,我希望关闭 SideMenu,而不是推送已呈现的 viewController。

这是用户界面:

enter image description here

这是我的 didSelectRow 代码,非常清楚:

    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
switch indexPath.row {
case 0:
let playerVC = NavigationHelper.shared.getStoryBoard().instantiateViewController(withIdentifier: "mainPage") as? MainViewController
navigationController?.pushViewController(playerVC!, animated: true)
case 1:
let historyVC = NavigationHelper.shared.getStoryBoard().instantiateViewController(withIdentifier: "historyPage") as? BroadcastsHistoryViewController
navigationController?.pushViewController(historyVC!, animated: true)
case 2:
let sendMessageVC = NavigationHelper.shared.getStoryBoard().instantiateViewController(withIdentifier: "messagingPage") as? MessaginViewController
navigationController?.pushViewController(sendMessageVC!, animated: true)
case 3:
let settingsVC = NavigationHelper.shared.getStoryBoard().instantiateViewController(withIdentifier: "settingPage") as? SettingsViewController
navigationController?.pushViewController(settingsVC!, animated: true)
case 4:
let aboutVC = NavigationHelper.shared.getStoryBoard().instantiateViewController(withIdentifier: "aboutPage") as? AboutAppViewController
navigationController?.pushViewController(aboutVC!, animated: true)
default: break
}
}

到目前为止,我已经尝试检测 topMost viewController,获取 presentingViewController 属性,但没有成功。谁能帮我以正确的方式处理它?<​​/p>

最佳答案

尝试将 var previousVC: UIViewController? 添加到 sideMenu Root View Controller (我们称之为 SideMenuVC)

然后在每个 View Controller 表单上,您将在其中显示添加的侧面菜单

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if let nextVC = segue.destination as? SideMenuVC {
nextVC.previousVC = self
}
}

然后在 XYZViewController 案例上写入

if let vc = previousVC as? XYZViewController{
//dismiss sidemenu
} else {
//instantiate and push ViewController
}

关于ios - 检测哪个 viewController 呈现了 SideMenu 并为其呈现实现适当的功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54751445/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com