How to use WKWebView in iOS with swift 5

How to use WKWebView in iOS with swift 5
May 1, 2020 No Comments Development,iOS Development Pushpendra Kumar

In this tutorial, I have explained to you that, How to use WKWebView in iOS with swift 5 programming language. So here we will start with the basic example. And In this example, I will show the complete result of how we can achieve this task. And also I will tell what are the techniques you need to keep in mind while you are working for the WKWebView. So follows the complete tutorial.

WKWebView in iOS with swift 5

Now you can watch the complete tutorial on the YouTube. So let’s continue with implementation.

Important

Starting in iOS 8.0 and OS X 10.10, use WKWebView to add web content to your app. Do not use UIWebView or WebView.

By Apple Developer Team

You can use the WKWebView class to embed web content in your app. To do so, create a WKWebView object, set it as the view, and send it a request to load web content. You need to write the below code for your WKWebView.

import UIKit
import WebKit

class WKWebViewController: UIViewController {
    
    var webView : WKWebView!
   
    override func viewDidLoad() {
        super.viewDidLoad()
        self.edgesForExtendedLayout = []
        
        let config = WKWebViewConfiguration()
        config.allowsInlineMediaPlayback = true
        
        webView = WKWebView(frame: view.bounds, configuration: config)
        
        self.view = webView
        
        let request = URLRequest(url: URL(string: "https://apple.com")!)
        webView.load(request)
    }
}

Wonderful..😎😎😊 You have done the great job. Now you can Build and run ▶️ your Xcode project and you will see the desire output. Bu if still you have any doubt then you can visit on the Youtube video and there you can check the complete process.  And After that, if you understand the complete code then please subscribe to my YouTube channel for the latest updates for the swift code and trick. 

And moreover you may like the following videos for boosting your skills.

Tags
About The Author
Pushpendra Kumar I am passionate about mobile application development and professional developer at Colour Moon Technologies Pvt Ltd (www.thecolourmoon.com). This website I have made so that I can meet with new challenges and can share here.

Leave a reply

Your email address will not be published. Required fields are marked *