Closed parthbarot closed 6 years ago
This part of code must be written in viewDidLoad function of your front view controller:
override func viewDidLoad() {
super.viewDidLoad()
self.btnMenuBar.addTarget(revealViewController(), action: #selector(SWRevealViewController.revealToggle(_:)), for: .touchUpInside)
self.revealViewController().panGestureRecognizer()
self.revealViewController().tapGestureRecognizer()
self.revealViewController().rearViewRevealWidth = 300
}
And remove the IBAction!
In your case, the first time you tap the button, btnMenubarClicked(_ :) is invoked and you just set the target/action, nothing else. The second time, the target/action you have set is invoked but not yours.
Hello, You were right now the issue is solved in each and every view controller. Thank you very much for the help. Thank You, Parth Barot.
On Tue, May 29, 2018 at 12:25 PM, Patrick notifications@github.com wrote:
This part of code must be written in viewDidLoad function of your front view controller:
override func viewDidLoad() { super.viewDidLoad() self.btnMenuBar.addTarget(revealViewController(), action: #selector(SWRevealViewController.revealToggle(_:)), for: .touchUpInside) self.revealViewController().panGestureRecognizer() self.revealViewController().tapGestureRecognizer() self.revealViewController().rearViewRevealWidth = 300 }
And remove the IBAction!
In your case, the first time you tap the button, btnMenubarClicked(_ :) is invoked and you just set the target/action, nothing else. The second time, the target/action you have set is invoked but not yours.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/John-Lluch/SWRevealViewController/issues/787#issuecomment-392671704, or mute the thread https://github.com/notifications/unsubscribe-auth/ARIja2QHLTkFECh46j2ptqEWnulBtKAdks5t3PDqgaJpZM4UQ5ri .
When I Click on the button on first time sidebar doesn't opens but when I again click on the button it opens. Why is that issue?
This is my code to open sidebar.
@IBAction func btnMenubarClicked( sender: Any) { if revealViewController() != nil { btnMenubar.addTarget(revealViewController(), action: #selector(SWRevealViewController.revealToggle(:)), for: .touchUpInside) self.revealViewController()?.rearViewRevealWidth = 300 view.addGestureRecognizer(self.revealViewController().panGestureRecognizer()) } }