Reputation: 23510
I have a View generated like this :
oneView = [[UIView alloc] initWithFrame:CGRectMake(x, y , w, h)];
oneView.tag = i;
UITapGestureRecognizer* recognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleTap2:)];
[recognizer setNumberOfTouchesRequired:1];
[oneView addGestureRecognizer:recognizer];
recognizer.delegate = self;
[recognizer release];
- (void)handleSingleTap2:(UITapGestureRecognizer *)recognizer {
int viewID = recognizer.view.tag;
NSLog(@"id : %d", viewID);
}
This works, but if I replace the UIView alloc with a UIWebView or UIImageView alloc, then touch event is not triggerred anymore.
How may I make it work ?
Upvotes: 0
Views: 893
Reputation: 2474
you must override
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer;
delegate function and return YES;
Upvotes: 0
Reputation: 8243
Regarding your question about the UIWebView
I suggest you have a look at drawnonward's Answer :
Does UIGestureRecognizer work on a UIWebView?
And for the UIImageView Part see this Tutorial:
UIImageView-with-zooming-tapping
I could not paste the code here but i think this will keep this area cleaner and easier to read.
Upvotes: 0
Reputation: 13164
set userInteractionEnabled=YES and if needed multipleTouchEnabled=YES
Upvotes: 0