Last active
August 22, 2017 20:12
-
-
Save ericjames/34a3e5cd16174d88fe4e2667f4e2a44f to your computer and use it in GitHub Desktop.
Swift 3 - Listen in on UIGestureRecognizer INSIDE of a UIWebView
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
class WebViewController: UIViewController, UIGestureRecognizerDelegate { | |
@IBOutlet weak var webView: UIWebView! | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
// WebView: Register tap | |
let panGesture = UITapGestureRecognizer(target: self, action: #selector(doneDragging(_:))) | |
panGesture.delegate = self | |
webView.addGestureRecognizer(panGesture) | |
} | |
// Function | |
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool { | |
print("Gesture",gestureRecognizer) | |
if (gestureRecognizer is UITapGestureRecognizer && gestureRecognizer.state == UIGestureRecognizerState.ended) { | |
return true | |
} else { | |
return false | |
} | |
} | |
func doneDragging(_ sender: UITapGestureRecognizer) | |
{ | |
print("Touches ended") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment