Passing scroll gesture to UIScrollView from anothe

2019-06-21 05:14发布

I do have a view that has a UIScrollView and over it there is a view that display some text. When the user swipes over this view that contains text the UIScrollView won't scroll. How to make this view transparent in a way it relays the swipe gesture to UIScrollView.

Thanks

3条回答
Deceive 欺骗
2楼-- · 2019-06-21 05:33

You can just set

myTextView.userInteractionEnabled = NO;

Or, if you're creating your view with Interface Builder, there's a check box there called 'User interaction enabled', just uncheck that.

查看更多
Root(大扎)
3楼-- · 2019-06-21 05:46

Check out the UIView hitTest Method

Returns the farthest descendant of the receiver in the view hierarchy (including itself) that contains a specified point.

- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
查看更多
Bombasti
4楼-- · 2019-06-21 05:46

Inside the -touchesXXXX:withEvent: methods of your custom view, call their super methods to forward touch events.

For example:

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

  ... 
  // process touchesBegan for this view
} 

Do the same things for touchesMoved, touchesEnded, and touchesCancelled.

查看更多
登录 后发表回答