iOS UIScrollView,用 2 根手指平移进行分页,用一根手指平移进行“手指指针”操作
我花了相当多的时间来弄清楚如何实现我想做的事情,但还没有找到合适的解决方案。我有一个 UIScrollView,其中我将 panGestureRecognizer 从一根手指识别更改为两根手指识别,因此分页仅在使用两根手指时才起作用。现在我想添加一个额外的 panGestureRecognizer,如果我用一根手指平移,它会显示一个课程器。我尝试通过向 UIScrollView 添加一个额外的 panGestureRecognizer 来实现这一点,但应用程序立即崩溃。因此,我想到添加一个透明的子视图,位于 UIScrollView 上方,并使用 resgin firstResponder 之类的东西将两个手指手势委托给 UIScrollView。我还想过覆盖 UIScrollView 的 pangestureRecognizer 并让它在我的“手指指针”(一个位于我现在触摸屏幕的中心的小点)所在的位置添加一个子视图。我完全不知道我应该走什么路以及如何实施。非常感谢您的帮助!多谢!
蒂莫
I spend quite some time to figure out how to achieve what I want to do but didn't find a proper solution for it, yet. I have a UIScrollView where I changed the panGestureRecognizer from one to two finger recognition so the paging only works when two fingers are used. Now I want to add an additional panGestureRecognizer that shows a courser if I'm panning with one finger. I tried that by just adding an additional panGestureRecognizer to the UIScrollView but then the app crashes immediately. So I thought of adding a subview that is transparent and positioned above the UIScrollView and that I delegate the two finger gestures to the UIScrollView with something like resgin firstResponder. I also thought of overwriting the pangestureRecognizer of the UIScrollView and let it add a Subview where my "fingerpointer"(a little point that is centered where I'm touching the screen right now) is located. I'm totally clueless what way I should go and how to implement it. Your help is greatly appreciated! Thanks a lot!
Timo
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的,这是第二次编辑我的回复。这可能对你有用。
如果您扩展 UIScrollView 您可以通过以下方式重写这些方法:
Ok, this is the second time editing my response. This might do the trick for you.
If you extend UIScrollView you can override these methods in this way: