如何在IBAction方法中添加按钮目标功能

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

我正在使用SWRevealViewController进行侧面菜单。当我点击menuBtn时,即时执行右切换操作。当我向右滑动时我想要一样可以任何一个请帮助我。

class Invoice: UIViewController {

@IBOutlet weak var menuBtn: UIButton!


override func viewDidLoad() {
        super.viewDidLoad()
        let revealViewController = self.revealViewController()
        menuBtn.addTarget(revealViewController, action: #selector(SWRevealViewController.rightRevealToggle(_:)), for: .touchUpInside)

}
@IBAction func swipeGesture(_ sender: UISwipeGestureRecognizer) {
        print("Swiped")
        //I want same action as i clicked on mentBtn
    }
}
swift swrevealviewcontroller uiswipegesturerecognizer
1个回答
1
投票

这样的事情应该有效:

@IBAction func swipeGesture(_ sender: UISwipeGestureRecognizer) {
    self.revealViewController().rightRevealToggle(self.menuBtn)
}
© www.soinside.com 2019 - 2024. All rights reserved.