Chapter 12. Web Views

A web view is a web browser, which is a powerful thing: it knows how to fetch resources through the internet, and it can render HTML and CSS, and can respond to JavaScript. It is a network communication device, as well as an interactive layout, animation, and media display engine.

In a web view, links and other ancillary resources work automatically. If your web view’s HTML refers to an image, the web view will fetch it and display it. If the user taps on a link, the web view will fetch that content and display it; if the link is to some sort of media (a sound or video file), the web view will allow the user to play it.

A web view can also display some other types of content commonly encountered as internet resources. It can display PDF files, as well as documents in such formats as .rtf, Microsoft Word (.doc and .docx), and Pages. (A Pages file that is actually a bundle must be compressed to form a single .pages.zip resource.)

Warning

A web view should also be able to display .rtfd files, but this feature is not working properly; Apple suggests that you convert to an attributed string as I described in Chapter 11 (specifying a document type of NSRTFDTextDocumentType), or use a QLPreviewController (Chapter 23).

The loading and rendering of a web view’s content takes time, and may involve networking. Your app’s interface, however, is not blocked or frozen while the content is loading. On the contrary, your interface remains accessible and operative. The web ...

Get Programming iOS 14 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.