Closed poowl closed 9 years ago
Where and how do you set the panGesture to your Navigation Bar?
At each of the four ViewControllers like this:
self.view.addGestureRecognizer(self.revealViewController().panGestureRecognizer())
self.revealViewController is not nil?
And d if you try this, what's happen? (objective-c: you have to adapt)
In viewDidLoad method:
[self.navigationController.navigationBar addGestureRecognizer:self.revealViewController.panGestureRecognizer];
I know it's off topic, but are there some good guides or examples to "adapt" objective c in swift? At this time I actually don't know what to do. Thanks!
At this time you can test replacing view by navigationController.navigationBar, no?
Ahhh okay, now I understand what you mean. But unfortunately your proposal isn't working. Now the panGestureRecognizer isn't working. I added a link to a zip of my project, maybe I did something wrong at another point?
https://drive.google.com/file/d/0B_DwuPXffCkrclRmSzZQLXViVW8/view?usp=sharing
Gesture Recognizers Are Attached to a View
Every gesture recognizer is associated with one view. By contrast, a view can have multiple gesture recognizers, because a single view might respond to many different gestures. For a gesture recognizer to recognize touches that occur in a particular view, you must attach the gesture recognizer to that view. When a user touches that view, the gesture recognizer receives a message that a touch occurred before the view object does. As a result, the gesture recognizer can respond to touches on behalf of the view.
So, for each view :
import UIKit
class FirstViewController: UIViewController {
@IBOutlet weak var FirstButton: UIBarButtonItem!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
FirstButton.target = self.revealViewController()
FirstButton.action = Selector("revealToggle:")
}
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
self.view.addGestureRecognizer(self.revealViewController().panGestureRecognizer())
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
Ahhh, okay that makes sense. Sorry, my fault, I should have read this info for myself. Thank you very much! No more issue here! Thanks!
Hello! I'm using the SWRevealViewController with four Views and four individual ViewControllers. On each View I got an icon at the navigation bar in the left corner and clicking on that icon is working on every View without problems. But the panGestureRecognizer is only working for the first time. If I'm at the first view and swipe, then it will work, but if I switch to the second view and than back to the first view, the swipe isn't working. I don't get any errors.
Could this be an issue with SWRevealViewController or rather with my programming?