在多个UIViews上滑动手指时如何检测特定UIView中的触摸 [英] How do you detect touches in specific UIView when sliding finger across mutiple UIViews
本文介绍了在多个UIViews上滑动手指时如何检测特定UIView中的触摸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要解决的情况是我有几个UIViews作为主UIView的子视图.我想做的是通过让手指在视图上滑动来更改其边框来突出显示视图的矩形.类似于在超文本链接上移动/拖动鼠标光标时发生的事情.
The scenario I am trying to solve is I have several UIViews as subviews of a master UIView. What I want to be able to do is highlight a views rect by lets say changing its border as a finger slides across the view..similar to what happens when you move/drag your mouse cursor over a hypertext link.
推荐答案
您可以在touchesMoved:
方法内部获取触摸的位置,然后询问主UIView触摸了哪个视图:
You can get the location of the touch inside your touchesMoved:
method, then ask the master UIView which view was touched:
- (void)touchesMoved: (NSSet *)touches withEvent:(UIEvent *)event {
UIView *subview = [masterView hitTest:[[touches anyObject] locationInView:masterView] withEvent:nil];
...
}
这篇关于在多个UIViews上滑动手指时如何检测特定UIView中的触摸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文