如何在ios的uipageviewcontroller上单击一下禁用页面卷曲

发布于 2024-12-28 20:24:38 字数 900 浏览 1 评论 0原文

我在根视图控制器的底部有图像的缩略图视图。它在页面中间工作正常,但是当我单击缩略图视图的左角或右角时,它会卷曲页面视图而不是缩略图图像选择。

我尝试过以下功能,但该功能在我的情况下不起作用。

-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch

 {
        NSLog(@"overiding page curl feature");

        //Touch gestures below top bar should not make the page turn.

        //EDITED Check for only Tap here instead.

        if ([gestureRecognizer isKindOfClass:[UITapGestureRecognizer class]]) {


            CGPoint touchPoint = [touch locationInView:self.view];

            if (touchPoint.y > 40) {

                return NO;
            }

            else if (touchPoint.x > 50 && touchPoint.x < 430) {

//Let the buttons in the middle of the top bar receive the touch

                return NO;
            }
        }

 else{NSLog(@"in else case");}

        return YES;
    }

I have thumbnail view of images on the bottom of root view controller. It works fine in the middle of the page but when i single tap on the left or right corner of the thumbnail view it curls the page view instead of thumbnail image selection.

I have tried following function but this function does not work in my case.

-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch

 {
        NSLog(@"overiding page curl feature");

        //Touch gestures below top bar should not make the page turn.

        //EDITED Check for only Tap here instead.

        if ([gestureRecognizer isKindOfClass:[UITapGestureRecognizer class]]) {


            CGPoint touchPoint = [touch locationInView:self.view];

            if (touchPoint.y > 40) {

                return NO;
            }

            else if (touchPoint.x > 50 && touchPoint.x < 430) {

//Let the buttons in the middle of the top bar receive the touch

                return NO;
            }
        }

 else{NSLog(@"in else case");}

        return YES;
    }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

送你一个梦 2025-01-04 20:24:38

有点晚了,但我也遇到了这个问题,并用 this 解决了它。希望这可以帮助您或其他像我一样跌跌撞撞的人。还有其他一些很好的答案和讨论。

Bit late but I had this problem too and solved it with this. Hope that helps you or someone else stumbling around like I was. Some other good answers and discussion there too.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文