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
60
votes
8 answers

UIWebView delegate method shouldStartLoadWithRequest: equivalent in WKWebView?

I have a module inside my iOS 7+ app which is a UIWebView. The html page loads a javascript that creates custom-shaped buttons (using the Raphaeljs library). With UIWebView, I set delegate to self. The delegate method webView:…
invalidArgument
  • 2,289
  • 4
  • 24
  • 35
58
votes
6 answers

Set useragent in WKWebview

How do I set a custom useragent string in a WKWebView? I'm trying to embed the version of my app so that my server-side can see what features are available. I found the following method: let userAgent = "MyApp/1.33.7" request.setValue(userAgent,…
Pvel
  • 670
  • 1
  • 5
  • 11
57
votes
8 answers

WKWebView Persistent Storage of Cookies

I am using a WKWebView in my native iPhone application, on a website that allows login/registration, and stores the session information in cookies. I am trying to figure out how to persistently store the cookie information, so when the app…
haplo1384
  • 1,206
  • 1
  • 12
  • 29
56
votes
5 answers

Load local web files & resources in WKWebView

Unlike with UIWebView and previous versions of WKWebView (iOS 10 & macOS 10.12), the default load operation for local files has moved from Bundle.main.path to Bundle.main.url. Similarly, loadFileURL has also become the default function to load local…
JDev
  • 5,168
  • 6
  • 40
  • 61
56
votes
12 answers

WKWebView fails to load images and CSS using loadHTMLString(_, baseURL:)

Apple's recommendation: In apps that run in iOS 8 and later, use the WKWebView class instead of using UIWebView. Thus, I have replaced my good old UIWebView with a shiny new WKWebView. But what I thought to be an easy exercise (simply swapping the…
Mischa
  • 15,816
  • 8
  • 59
  • 117
52
votes
9 answers

WKWebView evaluate JavaScript return value

I need to change a function to evaluate JavaScript from UIWebView to WKWebView. I need to return result of evaluating in this function. Now, I am calling: [wkWebView evaluateJavaScript:call completionHandler:^(NSString *result, NSError *error) { …
redak105
  • 559
  • 1
  • 5
  • 6
51
votes
2 answers

WKWebView loads HTML content too slowly in iOS 9 using swift

I have been trying to integrate the WKWebView as a subview of another webview in a UIViewController. I've been able to load the content and communicate properly with the swift and JavaScript. However, the loading time of the HTML content without any…
Krish Lakshmanan
  • 760
  • 7
  • 13
49
votes
2 answers

Adding header view to WKWebView ScrollView

Has anyone managed to successfully add a header or footer view to a WKWebView ScrollView? I'm currently trying to do this using the method described here for a UIWebView Adding a header view to a UIWebView similar to Safari and Articles. When this…
Keith Peck
  • 499
  • 4
  • 5
48
votes
7 answers

Capture redirect url in wkwebview in ios

How do I capture the redirection url in when using WKWebView like if a webpage redirects to another page on submitting the username and password or some other data. I need to capture the redirected url. Is there any method in WKNavigationDelegate to…
Prabu Raj
  • 577
  • 1
  • 6
  • 11
48
votes
9 answers

How to read console logs of WKWebView programmatically

I am trying to read the console logs of a webapp that is loaded in my WKWebView programmatically. So far in my research it's not possible. How can I achieve this?
NaveenKumar
  • 600
  • 1
  • 5
  • 18
47
votes
1 answer

State of WKWebView on Cordova iOS 9?

iOS 8 introduced WKWebView, a modernised web view for iOS with more features, particularly notably JIT compilation for Javascript code which significantly improves performance. However WKWebView on iOS 8 had some bugs which prevented Cordova using…
AshleysBrain
  • 22,335
  • 15
  • 88
  • 124
46
votes
6 answers

Insert CSS into loaded HTML in UIWebView / WKWebView

I am successfully able to get HTML content and display into my UIWebView. But want to customize the content by adding an external CSS file. I can only change the size of text and font. I tried every possible solution to make changes but it does…
cole
  • 3,147
  • 3
  • 15
  • 28
45
votes
2 answers

WKWebView Content loaded function never get called

i try to get a function called after my Content inside WKWebView is fully loaded. I found the "didFinishNavigation" function at the Apple Swift WKNavigation Documentation. func webView(webView: WKWebView!, didFinishNavigation navigation:…
Darx
  • 1,516
  • 2
  • 13
  • 15
44
votes
2 answers

WKWebKit javascript execution when not attached to a view hierarchy

I want to switch to WKWebView from UIWebView. In my code, the web view instance is created offscreen (without attaching to the view hierarchy) and URL is loaded. When loading is done, the web view is presented to the user in a separate UIWindow…
Alex Lementuev
  • 598
  • 4
  • 6
43
votes
14 answers

How to delete WKWebview cookies

For now I am doing like this NSHTTPCookie *cookie; NSHTTPCookieStorage *storage = [NSHTTPCookieStorage sharedHTTPCookieStorage]; for (cookie in [storage cookies]) { [storage deleteCookie:cookie]; } But it is not working…
Pankaj Gaikar
  • 2,357
  • 1
  • 23
  • 29