How can I recognize the subdirectory of a UIImageView subclass inside a UIScrollView?

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 when I initialized my view, this calls:

self.userInteractionEnabled = YES;

      

But when the scroll view doesn't move and I click on my sub-tier multiple times, nothing happens. No log message. I know the UIScrollView actually waits for the moment if the user wants to scroll, but at some point he has to give up the wait and fire the event in the subview, right?

Is there something important that I might be missing here?

EDIT: Read my answer below if you have the same problem!

0


a source to share


1 answer


Instead of deleting my question, I think others may be interested in this issue. So the solution was calm: I just forgot to install

anSuperview.userInteractionEnabled = YES;

      



So, if your view, which should receive a touch event, is nested inside any other view, all its sub-blocks should be set to userInteractionEnabled = YES;

+1


a source







All Articles