Questions tagged [wkwebview]

A WKWebView object displays interactive web content. It is provided by Apple's WebKit which is available for macOS, iOS and tvOS as well.

A WKWebView object displays interactive web content. It is provided by Apple's Open Source Project WebKit and is available for macOS, iOS and tvOS as well.

Links:

3852 questions
43
votes
4 answers

WKWebView and NSURLProtocol not working

When using the old UIWebView you could catch the requests by implementing a custom NSURLProtocol. I us this to handle requests that requires authentication. I tried the same code and it doesn't work with the new WKWebView but my protocol class isn't…
Johan
  • 1,951
  • 1
  • 18
  • 22
42
votes
8 answers

Allow unverified ssl certificates in WKWebView

I'm trying to load a HTTPS url with an self-signed certificate in a WKWebView for iOS 8 and it keeps failing. The workaround used with UIWebView (using setAllowsAnyHTTPSCertificate from NSUrlRequest) doesn't seem to work. Does anyone know of any…
Roi
  • 421
  • 1
  • 4
  • 5
41
votes
2 answers

Swift 3 - Check if WKWebView has loaded page

My question: How do I check if a page in WKWebView has fully loaded in Xcode using Swift 3? This is my problem: Webpage 1: From this page I load Webpage 2 Webpage 2: I need to get html data from Webpage 2, but when I print the HTML data I get HTML…
Stef
  • 1,183
  • 1
  • 9
  • 12
41
votes
1 answer

Cookie sharing between multiple WKWebViews

I create a few WkWebViews in my app, but when cookies are set for one webview, they do not take effect in the other ones (i.e. the other webviews do not pass the same cookie back to the server). How can I get them to all use the same cookie storage?
weiyin
  • 6,819
  • 4
  • 47
  • 58
40
votes
11 answers

ITMS-90809: Deprecated API Usage - existing app that use UIWebView are no longer accepted

ITMS-90809: Deprecated API Usage - Apple will no longer accept submissions of new apps that use UIWebView as of April 30, 2020 and app updates that use UIWebView as of December 2020. Instead, use WKWebView for improved security and reliability. I…
Ragesh Pikalmunde
  • 1,333
  • 1
  • 20
  • 44
40
votes
8 answers

WKWebView does load resources from local document folder

In my Swift iOS app, I want to download some dynamic HTML pages from a remote server, save them in the document directory, and display those pages from document directory. I was using this to load the page: var…
Peter
  • 775
  • 1
  • 6
  • 12
40
votes
2 answers

IOS: Text Selection in WKWebView (WKSelectionGranularityCharacter)

I've got an app that uses a web view where text can be selected. It's long been an annoyance that you can't select text across a block boundary in UIWebView. WKWebView seems to fix this with a property on its configuration: selectionGranularity. …
Tom Hamming
  • 10,577
  • 11
  • 71
  • 145
39
votes
7 answers

How does one Print all WKWebView On AND Offscreen content OSX and iOS

This question is about printing ALL content (including off screen content) of WKWebView. Currently (still, as of iOS 10.2 or OSX 10.12) there is NO working solution and none of the supposed solutions on Stackoverflow work. Only provide an answer…
Cliff Ribaudo
  • 8,932
  • 2
  • 55
  • 78
39
votes
4 answers

How can I give WKWebView a colored background

I'm working on an app in which I load different html files with mostly dark backgrounds. Right now there's a small white flash when navigating from one page to another, presumably since the next page has not loaded yet. I'd like to get rid of that…
chicken
  • 1,579
  • 1
  • 13
  • 13
37
votes
5 answers

IOS9 WKWebView Access-Control-Allow-Origin

I load local html file on IOS WKWebview using loadFileURL: allowingReadAccessToURL.. But when I send ajax request, it fails. The error is: Origin null is not allowed by Access-Control-Allow-Origin. Can I set some properties to fix this error, like…
Haoru Zhan
  • 381
  • 3
  • 4
36
votes
5 answers

How can I retrieve a file using WKWebView?

There is a file (CSV) that I want to download. It is behind a login screen on a website. I wanted to show a WKWebView to allow the user to log in and then have the app download the file after they had logged in. I've tried downloading the file…
Devin McKaskle
  • 802
  • 1
  • 8
  • 15
35
votes
1 answer

WKWebView crashes in acceleratedAnimationDidStart

I'm having a crash occur on a client's app and other than a lot at the WTFCrash, I'm not getting much use out of the stack trace. I am using a WKWebView instance to show a web page that has some CSS based animations and a video. The issues occurs on…
TheGeoff
  • 3,860
  • 2
  • 23
  • 23
35
votes
9 answers

How to add HTTP headers in request globally for iOS in swift

func webView(webView: WKWebView!, decidePolicyForNavigationAction navigationAction: WKNavigationAction!, decisionHandler: ((WKNavigationActionPolicy) -> Void)!) { var request = NSMutableURLRequest(URL: navigationAction.request.URL) …
sandip
  • 419
  • 1
  • 6
  • 13
33
votes
2 answers

Position of cursor in WKWebView with an editable paragraph in iOS

Is there anyway to get the position of the cursor in a WKWebView in iOS that contains an editable paragraph (a paragraph with attributed contentEditable set to true)? EDIT: To add additional information, the editable div can contain other subnodes
papafe
  • 2,959
  • 4
  • 41
  • 72
33
votes
2 answers

What's the difference between UIWebView and WKWebView when loading local resources

I want to load local resources with webView. I built a demo with both UIWebView and WKWebView to do some test with the code below. let uiWebView = UIWebView(frame: self.view.bounds) self.view.addSubview(uiWebView) let wkWebView =…
Rufus
  • 640
  • 1
  • 7
  • 14