An iOS app allowing to browse websites, opening a custom viewer when navigating to PDF files.


Why did I do this?

As a teacher, I store my classes's content on a website, using PDFs for slides and documents. I wanted a simple way to use an iOS device when giving a class to browse my website and present my slides, without switching context between multiple apps.

What I learned

I used a webview to handle the web browsing part and a callback allows to decide what to do with every request the webview is about to execute. All I had to do was cancel the default navigation when detecting the request's destination url was a PDF and launch my own view controller. Viewing the PDF is also pretty straightforward, thanks to PDFKit introduced in iOS 11. I added some simple gesture to allow navigating through the PDF.