Passing scroll gesture to UIScrollView from another view

╄→гoц情女王★ 提交于 2019-12-10 14:22:44

问题


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


回答1:


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.




回答2:


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



回答3:


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.



来源:https://stackoverflow.com/questions/3720907/passing-scroll-gesture-to-uiscrollview-from-another-view

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!