IOS TOPICS

IOS Introduction
Swift UI Label
Swift UI Button
Swift UI Text Field
Swift UI Slider
Swift UI Switch
Swift UI Stepper
Swift UI Date Picker
Swift UI Segmented Control
Views
Table View
Collection Views
SCROLL VIEW
iOS Content View
iOS View Controllers
iOS Bar interface
iOS Navigation interface
iOS Architect Pattern
iOS Libraries
iOS Web request and parsing
iOS user defaults
iOS Coredata and database

Web View


Web View

WebView is an object that can show interactive web content and load HTML strings for an in-app browser within an iOS application. It's a WKWebView instance, which is derived from the UIView class.

class WKWebView : UIView

As previously stated, the WebView object may be used to load web information into an iOS application. To load web material, we just need to build a WKWebView object, set it as a view, and send it a request.

WKWebView Properties and Methods

The WKWebView class has attributes and methods that may be used to modify the webview's functionality. We can utilize the goBack() and goForward() methods to allow users to go backward and forward. We can utilize the Boolean attributes canGoBack and canGoForward to see if the user can travel in a specific direction.

Example: Creating WKWebView programmatically

import UIKit import WebKit class ViewController: UIViewController { var webView : WKWebView! let activityIndicator = UIActivityIndicatorView(style: .whiteLarge) override func viewDidLoad() { super.viewDidLoad() After loading the view, do any extra configuration. activityIndicator.startAnimating() webView = WKWebView() webView.navigationDelegate = self self.view = webView let loadURL = "https://www.javatpoint.com" let url = URL(string: loadURL)! webView.load(URLRequest(url: url)) activityIndicator.stopAnimating() webView.allowsBackForwardNavigationGestures = true } } extension ViewController : WKNavigationDelegate { func webView(_ webView: WKWebView, didFail navigation: WKNavigation!, withError error: Error) { activityIndicator.startAnimating() } didFinish navigation: WKNavigation!) func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) { activityIndicator.stopAnimating() } }