swiftswrevealviewcontrolleruiswipegesturerecognizer

How to add button target function in IBAction method


I am using SWRevealViewController for side menu. while i click on menuBtn, im performing right toggle operation. I want the same when i swipe right Can any one Please Help me with it.

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
    }
}

Solution

  • Something like this should work:

    @IBAction func swipeGesture(_ sender: UISwipeGestureRecognizer) {
        self.revealViewController().rightRevealToggle(self.menuBtn)
    }