gpt4 book ai didi

ios - Objective-c shouldRecognizeSimultaneouslyWithGestureRecognizer 禁用其他GestureRecognizer

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:02:57 28 4
gpt4 key购买 nike

我有 viewdeck Controller ,我可以通过向右滑动来打开左侧栏菜单。对于我的中心 View Controller ,我也有 uitableview。

问题是我可以向右滑动来打开菜单,同时我也可以滚动我的表格 View 。我需要一次只允许一个手势。

所以,我在这里检查

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer;

我是这样发现的。我需要禁用 UIPanGestureRecognizer 或 UIScrollViewPanGestureRecognizer 一次只允许 1 个手势。我可以知道该怎么做吗?

//(lldb) po gestureRecognizer
//<UIPanGestureRecognizer: 0x79eef4d0; state = Possible; view = <UIView 0x79ee36e0>; target= <(action=panned:, target=<IIViewDeckController 0x79edb1d0>)>>

//(lldb) po otherGestureRecognizer
//<UIScrollViewPanGestureRecognizer: 0x79ff32f0; state = Began; delaysTouchesEnded = NO; view = <UITableView 0x7c301e00>; target= <(action=handlePan:, target=<UITableView 0x7c301e00>)>>

最佳答案

您可以尝试将另一个手势识别器的 enabled 属性设置为 NO。我现在没有开发环境,但我记得以前做过类似的事情。像这样:

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizershouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer{
otherGestureRecognizer.enabled = NO;
return YES;
}

关于ios - Objective-c shouldRecognizeSimultaneouslyWithGestureRecognizer 禁用其他GestureRecognizer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26793003/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com