Last active
December 19, 2015 21:29
-
-
Save xandrucea/6020199 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Check tap on UIWebView | |
---------------------- | |
1. add UIGestureRecognizer to declaration (h.file) | |
2. create TapGestureRecognizer and add to webview | |
UITapGestureRecognizer *webViewTapped = [[UITapGestureRecognizer alloc] initWithTarget:self | |
action:@selector(showIntersticial)]; | |
webViewTapped.numberOfTapsRequired = 1; | |
webViewTapped.delegate = self; | |
[_webView addGestureRecognizer:webViewTapped]; | |
3. override delegate method | |
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer | |
{ | |
return YES; | |
} | |
4. write method to handle actions when tapped | |
- (void)showIntersticial{ | |
// do something when had been tapped | |
} | |
check if specific element had been clicked | |
------------------------------------------ | |
UITouch *touch = touches.anyObject; | |
CGPoint point = [touch locationInView:self.view]; | |
// check if selected element on screen is board | |
UIView *hitView = [self.canvasView hitTest:point withEvent:event]; | |
if(hitView == _canvasView){ | |
// my element | |
} else { | |
// not my element | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment