Reputation: 1112
How should I configurative my UIScrollView such that, a UIbutton's forControlEvents:UIControlStateHighlighted
can still be triggered when the scrollView is in the state of scrolling.
Now it simply stops the scrolling when touched, instead of highlighting the button even though the finger landed on it.
This is very expected, of course, but I would really appreaciate if someone can guide me to enabling button's touch event when scrolling.
Upvotes: 2
Views: 221
Reputation: 3055
Well, you could try to subclass UIScrollView and override the hitTest method like this:
-(id)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
id hitView = [super hitTest:point withEvent:event];
if (hitView == yourButton) {
return yourButton;
} else {
return hitView;
}
}
That way, when your button is being "hit", the button would receive the touch event instead of the UIScrollView.
Upvotes: 3