ios - 侧边菜单警告 : attempt to push a View Controller from where its navigationController == nil in swift

标签 ios swift button uinavigationcontroller side-menu

我在我的项目中添加了 jonkykong/SideMenu pod。如果我在侧菜单中添加 View Controller ,那么它工作正常。

给定从 View Controller 中的所有侧菜单按钮到 UISideMenuNavigationController 的 segue 模型

如果我在侧菜单中添加所有 viewController,那么它工作正常,但如果我如下所示:

UISideMenuNavigationController -> home(是一个 Collection View ) -> MakePaymentViewController -> PaymentOptionsViewController

在主页取消选择:

let nextViewController = self.storyboard?.instantiateViewController(withIdentifier: "MakePaymentViewController") as? MakePaymentViewController
self.navigationController?.pushViewController(nextViewController!, animated: true)

在 MakePaymentViewController makePaymentButton 中:

let makepayVC = self.storyboard?.instantiateViewController(withIdentifier: "MakePaymenyOptionsViewController") as! MakePaymenyOptionsViewController
makepayVC.amounText = totalAmount
self.present(makepayVC, animated: true)

如果我从 MakePaymenyOptionsViewController 的侧菜单按钮向 UISideMenuNavigationController 提供 segue 模型,那么我会收到以下错误

我不想在侧边菜单中使用 MakePaymenyOptionsViewController。

SideMenu Warning: attempt to push a View Controller from Optional() where its navigationController == nil. It must be embedded in a Navigation Controller for this to work.

最佳答案

MakePaymenyOptionsViewController 必须嵌入到 NavigationController 中才能正常工作。

关于ios - 侧边菜单警告 : attempt to push a View Controller from where its navigationController == nil in swift,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59109078/

相关文章:

ios - 自定义 iOS UITextView 文本

ios - 更改 timeAgo 使系统过期

ios - 以编程方式从 iphone 调用 USSD 代码

ios - 如何以正确的方式使用导航 Controller 实现标签栏 Controller

ios - 用于 YouTube 集成的 Cocoapods 安装

ios - CollectionView标题滚动时停止刷新/重新加载数据

arrays - 如何制作一个函数,将协议(protocol)中定义的任何函数作为其参数?

调整按钮大小时,chrome 上的 CSS 在 firefox 上表现不同

javascript - 事件监听器在 javascript 中无法正常工作

JavaScript 按钮没有响应