-
Notifications
You must be signed in to change notification settings - Fork 11
Home
Welcome to the WKWebView wiki which is destinated to developers!
A WKWebView object displays interactive web content. To do so, create such an object, set it as view and send it a request to load web content.
WKWebView is a subclass of the WebKit framework that displays web content in windows. The framework implements browser features such as following user-activated links, managing a back-forward list, and managing a history of recently visited pages.
WKWebView has two delegates: WKNavigationDelegate and WKUIDelegate.
The methods of the WKNavigationDelegate protocol help you implement custom behaviors that are triggered during a web view's process of accepting, loading, and completing a navigation request.
The WKUIDelegate class provides methods for presenting native user interface elements on behalf of a webpage.
WKWebView doesn't open links with target="_blank". Specific coding is required to handle this use case.
This demo app uses the following swift files:
- AppDelegate.swift
- ViewController.swift
- WebViewController.swift
The ViewController class handles at ScrollTextView to display information messages about the web loading process. An embedded container view refers to the WebViewController class that handles the WKWebView object by using the following methods:
- viewDidLoad
- output
- openSafari
- react
- 8 optional delegate functions (webView) related to WKNavigationDelegate and WKUIDelegate.
The "dummy" function reacts delegates the output of a message by the WebViewController class to the ViewController class. This is purely done as a showcase. It's not possible to use a backward output delegate process inside the webView delegate methods. Therefore Notifications are used in these cases to trigger the output.
Links:
- WKWebView, by Matt Thompson on NSHipster
- A Look at the WebKit Framework in iOS 8, by Joyce Echessa at appcoda
- WKWEBVIEW - slice of Safari in your app, by Shrutic at Swiftgazelle (A Swift engineer's diary)
- Creating a simple browser with WKWebView, by Paul Hudson at hackingwithswift
- Complete Guide to Implementing WKWebView by Junda Ong aka samwize