如何将平移手势事件重定向到父视图? [英] How can I redirect pan gesture events to parent views?

查看:33
本文介绍了如何将平移手势事件重定向到父视图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在滑动 UIView 中有一个 UIScrollView.滑动的 UIView 应该能够到达导航栏的顶部,如果用户仍在拖动手指,那么里面的 UIScrollView 也应该开始向上滑动.同样,如果您向下滑动 UIScrollView 并到达内容的顶部,则滑动的 UIView 应该开始向下滑动.

I have a UIScrollView inside a sliding UIView. The sliding UIView should be able to reach the top of the navigation bar, and if the user is still dragging their finger, the UIScrollView inside should start to slide upwards as well. Likewise, if you slide the UIScrollView down and you reach the top of the content, the sliding UIView should start to slide down.

我无法让这种行为按照我想要的方式工作.我专门使用 Xamarin.iOS 库,但如果有人能指出我正确的方向,我可以将 Objective-C 翻译成 C#.

I can't get this behavior to work the way I want it to. I am specifically using Xamarin.iOS library, but I can translate Objective-C into C# if someone can just point me in the right direction with this.

谢谢!

推荐答案

首先,滑动的 UIView 应该在它的 superView 的边界内滑动.其次,在滑动 UIView 时,滚动视图的手势应该失败,直到滑动 UIView 位于其父视图的顶部或底部.这些可以通过实现 UIGestureRecognizer 协议的 shouldBeRequiredToFailByGestureRecognizer 方法来完成.

Firstly the sliding UIView should slide inside the bounds of its superView. Secondly, when sliding the UIView, gestures of the scrollview should be failed until Sliding UIView is at top or at bottom of its superview. These can be done by implementing shouldBeRequiredToFailByGestureRecognizer method of UIGestureRecognizer protocol.

这里我上传了一个示例项目.里面的scrollview是一个tableview.

Here I uploaded a sample project. The scrollview inside is a tableview.

这篇关于如何将平移手势事件重定向到父视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆