Unable to add two gesture to a UIView
up vote
1
down vote
favorite
I have a UIView sideMenuView whose child is UIView goToAccountButton
let leftPanSwipe = UIPanGestureRecognizer(target: self, action: #selector(self.sideMenuTranslate))
sideMenuView.addGestureRecognizer(leftPanSwipe)
let goToAccountGestureTap = UILongPressGestureRecognizer(target: self, action: #selector(self.goToAccountGesture))
goToAccountGestureTap.minimumPressDuration = 0.0
goToAccountButton.addGestureRecognizer(goToAccountGestureTap)
When trying to left swipe on goToAccountButton which is a child of sideMenuView, only goToAccountGestureTap works and it doesn't left-swipe at all.
I am unable to understand how to make both UILongPressGestureRecognizer and UIPanGestureRecognizer work on goToAccountButton as expected and so stuck. Please help me find a solution to this. Thank you.
ios swift xcode
add a comment |
up vote
1
down vote
favorite
I have a UIView sideMenuView whose child is UIView goToAccountButton
let leftPanSwipe = UIPanGestureRecognizer(target: self, action: #selector(self.sideMenuTranslate))
sideMenuView.addGestureRecognizer(leftPanSwipe)
let goToAccountGestureTap = UILongPressGestureRecognizer(target: self, action: #selector(self.goToAccountGesture))
goToAccountGestureTap.minimumPressDuration = 0.0
goToAccountButton.addGestureRecognizer(goToAccountGestureTap)
When trying to left swipe on goToAccountButton which is a child of sideMenuView, only goToAccountGestureTap works and it doesn't left-swipe at all.
I am unable to understand how to make both UILongPressGestureRecognizer and UIPanGestureRecognizer work on goToAccountButton as expected and so stuck. Please help me find a solution to this. Thank you.
ios swift xcode
Consider priority based implementation in your multi gesture environment. For more info see developer.apple.com/documentation/uikit/…
– Ratul Sharker
Nov 19 at 13:36
stackoverflow.com/questions/9272333/…
– sleepwalkerfx
Nov 19 at 13:38
2
increase your minimumPressDuration to 1.0
– guru
Nov 19 at 14:28
stackoverflow.com/questions/41918256/…
– Abhijith Purushothaman
Nov 19 at 15:11
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I have a UIView sideMenuView whose child is UIView goToAccountButton
let leftPanSwipe = UIPanGestureRecognizer(target: self, action: #selector(self.sideMenuTranslate))
sideMenuView.addGestureRecognizer(leftPanSwipe)
let goToAccountGestureTap = UILongPressGestureRecognizer(target: self, action: #selector(self.goToAccountGesture))
goToAccountGestureTap.minimumPressDuration = 0.0
goToAccountButton.addGestureRecognizer(goToAccountGestureTap)
When trying to left swipe on goToAccountButton which is a child of sideMenuView, only goToAccountGestureTap works and it doesn't left-swipe at all.
I am unable to understand how to make both UILongPressGestureRecognizer and UIPanGestureRecognizer work on goToAccountButton as expected and so stuck. Please help me find a solution to this. Thank you.
ios swift xcode
I have a UIView sideMenuView whose child is UIView goToAccountButton
let leftPanSwipe = UIPanGestureRecognizer(target: self, action: #selector(self.sideMenuTranslate))
sideMenuView.addGestureRecognizer(leftPanSwipe)
let goToAccountGestureTap = UILongPressGestureRecognizer(target: self, action: #selector(self.goToAccountGesture))
goToAccountGestureTap.minimumPressDuration = 0.0
goToAccountButton.addGestureRecognizer(goToAccountGestureTap)
When trying to left swipe on goToAccountButton which is a child of sideMenuView, only goToAccountGestureTap works and it doesn't left-swipe at all.
I am unable to understand how to make both UILongPressGestureRecognizer and UIPanGestureRecognizer work on goToAccountButton as expected and so stuck. Please help me find a solution to this. Thank you.
ios swift xcode
ios swift xcode
asked Nov 19 at 12:58
Lesy Bancroft
43
43
Consider priority based implementation in your multi gesture environment. For more info see developer.apple.com/documentation/uikit/…
– Ratul Sharker
Nov 19 at 13:36
stackoverflow.com/questions/9272333/…
– sleepwalkerfx
Nov 19 at 13:38
2
increase your minimumPressDuration to 1.0
– guru
Nov 19 at 14:28
stackoverflow.com/questions/41918256/…
– Abhijith Purushothaman
Nov 19 at 15:11
add a comment |
Consider priority based implementation in your multi gesture environment. For more info see developer.apple.com/documentation/uikit/…
– Ratul Sharker
Nov 19 at 13:36
stackoverflow.com/questions/9272333/…
– sleepwalkerfx
Nov 19 at 13:38
2
increase your minimumPressDuration to 1.0
– guru
Nov 19 at 14:28
stackoverflow.com/questions/41918256/…
– Abhijith Purushothaman
Nov 19 at 15:11
Consider priority based implementation in your multi gesture environment. For more info see developer.apple.com/documentation/uikit/…
– Ratul Sharker
Nov 19 at 13:36
Consider priority based implementation in your multi gesture environment. For more info see developer.apple.com/documentation/uikit/…
– Ratul Sharker
Nov 19 at 13:36
stackoverflow.com/questions/9272333/…
– sleepwalkerfx
Nov 19 at 13:38
stackoverflow.com/questions/9272333/…
– sleepwalkerfx
Nov 19 at 13:38
2
2
increase your minimumPressDuration to 1.0
– guru
Nov 19 at 14:28
increase your minimumPressDuration to 1.0
– guru
Nov 19 at 14:28
stackoverflow.com/questions/41918256/…
– Abhijith Purushothaman
Nov 19 at 15:11
stackoverflow.com/questions/41918256/…
– Abhijith Purushothaman
Nov 19 at 15:11
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
As @Ratul Sharker was hinting at, you need to make one of the gestures take priority. You probably want the pan to take priority, so add
goToAccountGestureTap.require(toFail: leftPanSwipe)
after you've set up the long-press gesture. This way, the long-press will only be checked for if the gesture isn't recognized as a pan gesture.
Mentioning this makes goToAccountGestureTap not work at all. How should I improve this?
– Lesy Bancroft
Nov 20 at 5:52
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
As @Ratul Sharker was hinting at, you need to make one of the gestures take priority. You probably want the pan to take priority, so add
goToAccountGestureTap.require(toFail: leftPanSwipe)
after you've set up the long-press gesture. This way, the long-press will only be checked for if the gesture isn't recognized as a pan gesture.
Mentioning this makes goToAccountGestureTap not work at all. How should I improve this?
– Lesy Bancroft
Nov 20 at 5:52
add a comment |
up vote
0
down vote
As @Ratul Sharker was hinting at, you need to make one of the gestures take priority. You probably want the pan to take priority, so add
goToAccountGestureTap.require(toFail: leftPanSwipe)
after you've set up the long-press gesture. This way, the long-press will only be checked for if the gesture isn't recognized as a pan gesture.
Mentioning this makes goToAccountGestureTap not work at all. How should I improve this?
– Lesy Bancroft
Nov 20 at 5:52
add a comment |
up vote
0
down vote
up vote
0
down vote
As @Ratul Sharker was hinting at, you need to make one of the gestures take priority. You probably want the pan to take priority, so add
goToAccountGestureTap.require(toFail: leftPanSwipe)
after you've set up the long-press gesture. This way, the long-press will only be checked for if the gesture isn't recognized as a pan gesture.
As @Ratul Sharker was hinting at, you need to make one of the gestures take priority. You probably want the pan to take priority, so add
goToAccountGestureTap.require(toFail: leftPanSwipe)
after you've set up the long-press gesture. This way, the long-press will only be checked for if the gesture isn't recognized as a pan gesture.
answered Nov 19 at 15:35
NRitH
7,47212431
7,47212431
Mentioning this makes goToAccountGestureTap not work at all. How should I improve this?
– Lesy Bancroft
Nov 20 at 5:52
add a comment |
Mentioning this makes goToAccountGestureTap not work at all. How should I improve this?
– Lesy Bancroft
Nov 20 at 5:52
Mentioning this makes goToAccountGestureTap not work at all. How should I improve this?
– Lesy Bancroft
Nov 20 at 5:52
Mentioning this makes goToAccountGestureTap not work at all. How should I improve this?
– Lesy Bancroft
Nov 20 at 5:52
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53375164%2funable-to-add-two-gesture-to-a-uiview%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Consider priority based implementation in your multi gesture environment. For more info see developer.apple.com/documentation/uikit/…
– Ratul Sharker
Nov 19 at 13:36
stackoverflow.com/questions/9272333/…
– sleepwalkerfx
Nov 19 at 13:38
2
increase your minimumPressDuration to 1.0
– guru
Nov 19 at 14:28
stackoverflow.com/questions/41918256/…
– Abhijith Purushothaman
Nov 19 at 15:11