Unable to add two gesture to a UIView
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 |
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 '18 at 13:36
stackoverflow.com/questions/9272333/…
– sleepwalkerfx
Nov 19 '18 at 13:38
2
increase your minimumPressDuration to 1.0
– guru
Nov 19 '18 at 14:28
stackoverflow.com/questions/41918256/…
– Abhijith Purushothaman
Nov 19 '18 at 15:11
add a comment |
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 '18 at 12:58
Lesy BancroftLesy Bancroft
63
63
Consider priority based implementation in your multi gesture environment. For more info see developer.apple.com/documentation/uikit/…
– Ratul Sharker
Nov 19 '18 at 13:36
stackoverflow.com/questions/9272333/…
– sleepwalkerfx
Nov 19 '18 at 13:38
2
increase your minimumPressDuration to 1.0
– guru
Nov 19 '18 at 14:28
stackoverflow.com/questions/41918256/…
– Abhijith Purushothaman
Nov 19 '18 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 '18 at 13:36
stackoverflow.com/questions/9272333/…
– sleepwalkerfx
Nov 19 '18 at 13:38
2
increase your minimumPressDuration to 1.0
– guru
Nov 19 '18 at 14:28
stackoverflow.com/questions/41918256/…
– Abhijith Purushothaman
Nov 19 '18 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 '18 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 '18 at 13:36
stackoverflow.com/questions/9272333/…
– sleepwalkerfx
Nov 19 '18 at 13:38
stackoverflow.com/questions/9272333/…
– sleepwalkerfx
Nov 19 '18 at 13:38
2
2
increase your minimumPressDuration to 1.0
– guru
Nov 19 '18 at 14:28
increase your minimumPressDuration to 1.0
– guru
Nov 19 '18 at 14:28
stackoverflow.com/questions/41918256/…
– Abhijith Purushothaman
Nov 19 '18 at 15:11
stackoverflow.com/questions/41918256/…
– Abhijith Purushothaman
Nov 19 '18 at 15:11
add a comment |
1 Answer
1
active
oldest
votes
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 '18 at 5:52
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
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
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
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 '18 at 5:52
add a comment |
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 '18 at 5:52
add a comment |
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 '18 at 15:35
NRitHNRitH
7,68222733
7,68222733
Mentioning this makes goToAccountGestureTap not work at all. How should I improve this?
– Lesy Bancroft
Nov 20 '18 at 5:52
add a comment |
Mentioning this makes goToAccountGestureTap not work at all. How should I improve this?
– Lesy Bancroft
Nov 20 '18 at 5:52
Mentioning this makes goToAccountGestureTap not work at all. How should I improve this?
– Lesy Bancroft
Nov 20 '18 at 5:52
Mentioning this makes goToAccountGestureTap not work at all. How should I improve this?
– Lesy Bancroft
Nov 20 '18 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.
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 '18 at 13:36
stackoverflow.com/questions/9272333/…
– sleepwalkerfx
Nov 19 '18 at 13:38
2
increase your minimumPressDuration to 1.0
– guru
Nov 19 '18 at 14:28
stackoverflow.com/questions/41918256/…
– Abhijith Purushothaman
Nov 19 '18 at 15:11