gpt4 book ai didi

ios - interactivePopGestureRecognizer 干扰 UIScrollView

转载 作者:行者123 更新时间:2023-11-28 21:49:06 25 4
gpt4 key购买 nike

我有一个 UIScrollView,其框架与包含的 View Controller 相同。

当 ScrollView 的缩放比例大于 1 时,从屏幕左侧 50% 开始从左向右滑动会导致 interactivePopGestureRecognizer 激活并关闭 View Controller 。这仅在设备横向时发生。纵向时效果很好。

是否需要任何特殊处理才能使此手势在 ScrollView 中正常工作?

最佳答案

1、将 interactivePopGestureRecognizer delegate 设置为 self (Custom UINavigationController)

self.interactivePopGestureRecognizer.delegate = self;

2、启用同时识别UIScrollView UIGestureRecognizer

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
if (self.interactivePopGestureRecognizer == gestureRecognizer) {
if ([otherGestureRecognizer.view isKindOfClass:UIScrollView.class]) {
UIScrollView *scrollView = (UIScrollView *)otherGestureRecognizer.view;
if ((scrollView.contentSize.width > CGRectGetWidth(self.view.bounds) && scrollView.contentOffset.x == 0)) {
return YES;
}
}
}

return NO;
}

关于ios - interactivePopGestureRecognizer 干扰 UIScrollView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28972502/

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