如何在 IBAction 方法中添加按钮目标函数
How to add button target function in IBAction method
我正在使用 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
}
}
像这样的东西应该可以工作:
@IBAction func swipeGesture(_ sender: UISwipeGestureRecognizer) {
self.revealViewController().rightRevealToggle(self.menuBtn)
}
我正在使用 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
}
}
像这样的东西应该可以工作:
@IBAction func swipeGesture(_ sender: UISwipeGestureRecognizer) {
self.revealViewController().rightRevealToggle(self.menuBtn)
}