I am using the PDFKit native framework which is available for iOS 11 only and my project targets older iOS versions.
Xcode asked me to mark the whole UIViewController
class as @available(iOS 11.0, *)
I'd like to handle viewing the PDF on older iOS versions in the same UIViewController
using a different UIView
that's going to use a UIWebView
or a 3rd party library. How can I achieve that?
You can set this condition for version specific execution on same view controller.
if #available(iOS 11.0, *) {
let pdfView = PDFView(frame: UIScreen.main.bounds)
let url = Bundle.main.url(forResource: "How", withExtension: "pdf")
pdfView.document = PDFDocument(url: url!)
self.view.addSubview(pdfView)
} else {
// Fallback on earlier versions
}