gpt4 book ai didi

ios - SWRevealViewController 切换不适用于自定义导航栏按钮

转载 作者:搜寻专家 更新时间:2023-11-01 07:26:03 27 4
gpt4 key购买 nike

我正在使用 SWRevealViewController 在 Swift 2.0 中显示侧边菜单 我已经从 GitHub 下载了文件,创建了桥接头并正确连接了转场。我正在创建一个自定义按钮,但“显示切换” Action 没有触发。我哪里出错了?

super.viewDidLoad()
self.navigationController?.navigationBar.topItem?.title = "DASHBOARD"
self.navigationController!.navigationBar.tintColor = UIColor.whiteColor()
self.navigationController!.navigationBar.titleTextAttributes =
[NSForegroundColorAttributeName: UIColor.whiteColor()]
self.navigationController!.navigationBar.titleTextAttributes = [ NSFontAttributeName: UIFont(name: "Teko-Regular", size: 26)!]
self.navigationController?.navigationBar.barTintColor = UIColor.redColor()
let btnName = UIButton()
btnName.setImage(UIImage(named: "LeftNavItem"), forState: .Normal)
btnName.frame = CGRectMake(0, 0, 20, 20)

let leftBarButton = UIBarButtonItem()
leftBarButton.customView = btnName
self.navigationItem.leftBarButtonItem = leftBarButton
if self.revealViewController() != nil {
//print(self.revealViewController())
leftBarButton.target = self.revealViewController()
leftBarButton.action = Selector("revealToggle:")

self.view.addGestureRecognizer(self.revealViewController().panGestureRecognizer())
}

手势识别器正确触发,但“revealToggle:”没有触发,这是怎么回事?

最佳答案

class Name: SWRevealViewControllerDelegate

override func viewDidLoad() {
super.viewDidLoad()

self.revealViewController().delegate = self

}

关于ios - SWRevealViewController 切换不适用于自定义导航栏按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36160156/

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