问题
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