I have built an App an I'm about to finish my project.
And I need to put a imprint as a pdf-file in my App (legal reasons), which I thought would be no problem. But I can't figure out what I need to do to get a Close Button to just close the PDF File..
My code:
@IBAction func test(_ sender: Any) {
let pdfView = PDFView()
pdfView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(pdfView)
pdfView.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor).isActive = true
pdfView.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor).isActive = true
pdfView.topAnchor.constraint(equalTo: view.topAnchor, constant:25).isActive = true
pdfView.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor).isActive = true
guard let path = Bundle.main.url(forResource: "ImpressumDatenschutz", withExtension: "pdf") else { return }
if let document = PDFDocument(url: path) {
pdfView.document = document
}
}
I didn't find any other option than putting a button in the upper left corner with a segue that goes back to the page that was open before the PDF was opened. I guess that is good enough for the beginning.
@IBAction func backTapped(_ sender: Any) {
performSegue(withIdentifier: "impressumToFirstVC", sender: self)
}