An object that displays interactive web content, such as for an in-app browser.
- iOS 8.0+
- macOS 10.10+
You can use the
WKWeb class to embed web content in your app. To do so, create a
WKWeb object, set it as the view, and send it a request to load web content.
After creating a new
WKWeb object using the
init method, you need to load the web content. Use the
load method to begin loading local HTML files or the
load method to begin loading web content. Use the
stop method to stop loading, and the
loading property to find out if a web view is in the process of loading. Set the delegate property to an object conforming to the
WKUIDelegate protocol to track the loading of web content. See Listing 1 for an example of creating a
To allow the user to move back and forward through the webpage history, use the
go methods as actions for buttons. Use the
can properties to disable the buttons when the user can’t move in a direction.
By default, a web view automatically converts telephone numbers that appear in web content to Phone links. When a Phone link is tapped, the Phone app launches and dials the number. To turn off this default behavior, set the
data property with a
WKData bitfield that does not contain the
You can also use the
set to programmatically set the scale of web content the first time it is displayed in a web view. Thereafter, the user can change the scale using gestures.