简体   繁体   English

在uiscrollview中处理触摸事件

[英]Handling touch events in uiscrollview

I have a UIScrollView and an UIImageView as its subview. 我有一个UIScrollView和一个UIImageView作为其子视图。 I want to draw on the imageview in response to the single touches. 我想在imageview上绘制以响应单个触摸。 And I want to zoom and pan the image view in the scroll view on pinch and pan gestures respectively. 我想分别在缩放和平移手势的滚动视图中缩放和平移图像视图。 I found many solutions. 我找到了很多解决方案。 But its not perfect. 但是它并不完美。 Please give me a straight forward solution. 请给我一个直接的解决方案。

在将UIScrollview子类化后使用。请参阅链接 。如果您正在为iphone4 OS做应用程序,请尝试使用UIGestureRecogniser。请在Apple网站中查看其示例代码。

If you are only using the scrollview for panning and zooming, I would suggest subclassing UIImageView to provide that functionality yourself along with the drawing. 如果仅将scrollview用于平移和缩放,则建议对UIImageView进行子类化,以随图纸一起提供该功能。 This will allow you to have finer control over it and quicker code. 这将使您可以更好地控制它并更快地编写代码。 A scrollview is not very good at allowing complex gestures within it. 滚动视图在允许其中包含复杂手势方面不是很好。 (other than taps) (水龙头除外)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM