Swift4 - WkwebView warning of Could not signal service com.apple.WebKit
13,638
I have tried to encode parameter and Its working fine for me. Please check below code.
var wkWebView = WKWebView()
override func viewDidLoad()
{
super.viewDidLoad()
self.automaticallyAdjustsScrollViewInsets = false
self.wkWebView.translatesAutoresizingMaskIntoConstraints = false
self.wkWebView.frame = CGRect.init(x: 0, y: 0, width: self.wkWebView.frame.size.width, height: self.wkWebView.frame.size.height)
self.view.addSubview(wkWebView)
loadUrl()
}
override func viewWillLayoutSubviews()
{
super.viewWillLayoutSubviews()
self.wkWebView.frame = CGRect.init(x: 0, y: 0, width: self.view.frame.size.width, height: self.view.frame.size.height)
self.wkWebView.contentMode = .scaleAspectFit
}
func loadUrl()
{
let webConfiguration = WKWebViewConfiguration()
webConfiguration.allowsInlineMediaPlayback = true
let url_join = "v=1p38GWfCIhQ"
let myURL = URL(string: "https://www.youtube.com/watch?")
var myRequest = URLRequest(url: myURL!)
myRequest.httpMethod = "POST"
myRequest.httpBody = url_join.data(using: String.Encoding.utf8)
wkWebView.load(myRequest)
}
I hope It will also work for you. :)
Related videos on Youtube
Author by
tolerate_Me_Thx
Updated on June 04, 2022Comments
-
tolerate_Me_Thx almost 2 years
I have a log when I load
youtube
URL inWKWebView
.
I have searched the same title of my question instackOverFlow
.
But it didn't work for me.
What's wrong with my code?
And I useswift4
&xcode9.2
.
Thanks.Warning like this:
Could not signal service com.apple.WebKit.Networking: 113: Could not find specified service
import UIKit import WebKit class DetailViewController: UIViewController { var videoId: String = "" var videoTitle: String = "" override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. loadUI() } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } func loadUI() { view.backgroundColor = UIColor.white naviSetting() webViewSetting() } func naviSetting() { self.title = videoTitle } func webViewSetting() { let webview = WKWebView(frame: CGRect(x: 0, y: 0, width: self.view.frame.width, height: self.view.frame.height)) let url = URL(string: "https://www.youtube.com/watch?v=\(self.videoId)") let request = URLRequest(url: url!) webview.load(request) self.view.addSubview(webview) } }
-
Vinaykrishnan about 6 yearsDid you see this too stackoverflow.com/questions/44585980/…
-
tolerate_Me_Thx about 6 yearsYes, And it seems not work for me.
-
iOS Developer about 6 years@tolerate_Me_Thx Please check my Answer.
-
iOS Developer about 6 years@tolerate_Me_Thx Please accept my answer if you have fixed your error. Thanks in Advance.
-