I tried it with this code in my UIScrollView-subclass:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
NSLog(@"he/she touched me");
}
I also made sure that in the initialization of my view, this gets called:
self.userInteractionEnabled = YES;
But when the scroll view doesn't move and i tap on my subview a few times, nothing happens. No log message. I know that the UIScrollView actually waits a moment if the user would like to scroll, but at some point it should give up waiting and fire the event to the subview, right?
Is there something important that I might missed here?
EDIT: Read my answer below, if you have the same problem!
Instead of deleting my question I think others may be interested in that problem. So, the solution was quiet simple: I just forgot to set
anSuperview.userInteractionEnabled = YES;
So, if your view that must receive a touch event is nested inside any other view, all it's subviews have to be set to userInteractionEnabled = YES;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.