Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Close revealviewcontroller when tapped on the page #821

Open
mustafashaheen1 opened this issue Oct 5, 2020 · 4 comments
Open

Close revealviewcontroller when tapped on the page #821

mustafashaheen1 opened this issue Oct 5, 2020 · 4 comments

Comments

@mustafashaheen1
Copy link

I am using swift and xocde 12. And I am using TableViewController for the menu. I have tried following solutions but they didn't work.

`override func touchesBegan(_ touches: Set, with event: UIEvent?) {
if let touch = touches.first {
if self.revealViewController() != nil {
self.view.addGestureRecognizer(self.revealViewController().tapGestureRecognizer())
}
}

    super.touchesBegan(touches , with:event)
}`

`if self.revealViewController() != nil {

    self.view.addGestureRecognizer(self.revealViewController().panGestureRecognizer())
    self.view.addGestureRecognizer(self.revealViewController().tapGestureRecognizer())
}`
@iDevelopper
Copy link

Override touchesBegan is not needed!
addGestureRecognizer is not needed!

Reading the documentation in the .h file:
Just do it in the viewDidLoad of your main view controller:

class MainViewController: UITabBarController, SWRevealViewControllerDelegate {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        self.revealViewController().tapGestureRecognizer()
        self.revealViewController().panGestureRecognizer()
        // ...

And the rear view will be closed automatically.

@mustafashaheen1
Copy link
Author

I just tried this didn't work. I have a UINavigationController as front not UITabBarController and TableViewController as rear

@iDevelopper
Copy link

It was an example. Just call revealViewController().tapGestureRecognizer in your main view controller.

@mustafashaheen1
Copy link
Author

I actually did that but still doesn't work. Just one thing the front page the whole view is google map where user taps. Can that be an issue? Here is my current code:

`import UIKit
import SWRevealViewController
class HomePageNavigationViewController: UINavigationController , SWRevealViewControllerDelegate{

override func viewDidLoad() {
    super.viewDidLoad()
    self.revealViewController().tapGestureRecognizer()
    self.revealViewController().panGestureRecognizer()
    // Do any additional setup after loading the view.
}`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants