将滚动手势从另一个视图传递到UIScrollView

时间:2010-09-15 19:05:55

标签: iphone uiscrollview gesture uigesturerecognizer swipe

我有一个有UIScrollView的视图,在它上面有一个显示一些文本的视图。 当用户在包含文本的视图上滑动时,UIScrollView将不会滚动。如何以将滑动手势中继到UIScrollView的方式使此视图透明。

由于

3 个答案:

答案 0 :(得分:2)

你可以设置

myTextView.userInteractionEnabled = NO;

或者,如果您使用Interface Builder创建视图,则会出现一个名为“启用了用户交互”的复选框,只需取消选中该项。

答案 1 :(得分:0)

查看UIView hitTest Method

  

返回包含指定点的视图层次结构(包括其自身)中接收器的最远后代。

- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event

答案 2 :(得分:-1)

在自定义视图的-touchesXXXX:withEvent:方法中,调用其超级方法来转发触摸事件。

例如:

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
  // forward touchesBegan to super class
  [super touchesBegan:touches withEvent:event];

  ... 
  // process touchesBegan for this view
} 

为touchesMoved,touchesEnded和touchesCancelled执行相同的操作。