UIScrollView和内容需要触摸移动事件 [英] UIScrollView and content with requires touch move events

查看:56
本文介绍了UIScrollView和内容需要触摸移动事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个视图,该视图使用单点触摸事件(单指)进行绘制(线条,循环,文本等).现在,我想将此视图放入UIScrollView内,这将允许缩放和平移.当然,需要两个手指来执行缩放和平移.

I have a view which is using single touch events (single finger) for drawing (lines, cycles, text, and so on). Now I want to put this view inside of UIScrollView, which will allow zooming and panning. Of course two fingers are required to perform both zooming and panning.

这样做的模式是什么?当UIScrollView的内容仅接受单击(仅包含按钮)时,我仅找到了一些示例.当内容也需要触摸动作时,什么也不做.

What is the pattern do do that? I've found only examples when contents of UIScrollView accepts only single clicks (it contains only a buttons). Nothing what to do when contents require also touch moves.

推荐答案

访问UIScrollView上的panGestureRecognizer属性,并将其minimumNumberOfTouches属性设置为两个:

Access the panGestureRecognizer property on the UIScrollView, and set its minimumNumberOfTouches property to two:

myScrollView.panGestureRecognizer.minimumNumberOfTouchesRequired = 2;

这篇关于UIScrollView和内容需要触摸移动事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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