gpt4 book ai didi

ios - 触摸按钮时无法将 View Controller 插入滑出菜单

转载 作者:行者123 更新时间:2023-11-30 13:22:09 28 4
gpt4 key购买 nike

我使用KYDrawercontroller滑出菜单我编写代码,当触摸 uitableview 中的按钮时推送 View Controller ,但它不推送这是我的代码

@IBAction func m01(sender: AnyObject) {
let mainnav = self.storyboard!.instantiateViewControllerWithIdentifier("m02") as! UINavigationController //maindrawer
let mainnav2 = self.storyboard!.instantiateViewControllerWithIdentifier("mm") as! page1ViewController //pagetopush
mainnav.pushViewController(mainnav2, animated: true)

}

在我的项目中查看https://github.com/salution/slide

最佳答案

使用下面的代码替换您的代码

@IBAction func m01(sender: AnyObject) {
print("touched")
let mainnav2 = self.storyboard!.instantiateViewControllerWithIdentifier("mm") as! page1ViewController
let rootVC = UIApplication.sharedApplication().keyWindow?.rootViewController
let childrenVC = rootVC?.childViewControllers
let nc = childrenVC?.first as? UINavigationController
if let DrawerTableViewController = navigationController?.parentViewController as? KYDrawerController{
DrawerTableViewController.setDrawerState(.Closed, animated: true)
}
nc?.pushViewController(mainnav2, animated: true)

}

我更喜欢 UIViewControllerAnimatedTransitioning 协议(protocol)来呈现你的 UI 效果

关于ios - 触摸按钮时无法将 View Controller 插入滑出菜单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37650826/

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