Created
September 10, 2020 19:16
-
-
Save Enriquecm/90a48b4b9c9bba395b09466cc1d63f88 to your computer and use it in GitHub Desktop.
Handle links and gestures on PDFView
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 PDFViewController: UIViewController { | |
@IBOutlet weak var viewPdf: PDFView! | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
setupPDF() | |
} | |
private func setupPDF() { | |
// ... | |
// Handle pdf links | |
viewPdf.enableDataDetectors = true | |
// ... | |
// Tap to toggle tools | |
let gesture = UITapGestureRecognizer(target: self, action: #selector(toggleTools)) | |
gesture.delegate = self | |
self.view.addGestureRecognizer(gesture) | |
} | |
// MARK: Actions | |
@objc | |
private func toggleTools() { | |
// Handle tap gesture | |
// ... | |
} | |
} | |
extension PDFViewController: UIGestureRecognizerDelegate { | |
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool { | |
return true | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment