wkwebviewconfiguration

WKWebView Cookies

自古美人都是妖i 提交于 2019-12-09 23:45:45
问题 I'm using the below mentioned approach to set cookies in a WKWebview : Can I set the cookies to be used by a WKWebView? But the cookies that I have set are being duplicated in the AJAX calls. I mean they are being repeated twice. Here is the code snippet that I used: NSString *strURL = DASHBOARDURL; NSURL *url = [NSURL URLWithString:strURL]; NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init]; [request setURL:url]; NSMutableString *script = [[NSMutableString alloc] init];

How to autoscale the contents of a WKWebView?

你说的曾经没有我的故事 提交于 2019-12-06 06:46:38
问题 To autoscale a webpage inside a good old WebView in Swift, all I had to do was: var w:UIWebView w.scalesPageToFit=true I cannot find an equivalent method for a WKWebView, and webpages appear too big in my app. How can I autoscale the contents of a WKWebView? -I am using Xcode 7 and Swift 回答1: Here is my solution: extension WKWebView { private struct key { static let scale = unsafeBitCast(Selector("scalesPageToFit"), UnsafePointer<Void>.self) } private var sourceOfUserScript: String { return "

iOS WKWebView Handle File Download

北慕城南 提交于 2019-12-06 06:20:12
问题 I am facing the following problem: In a web interface, file downloads are triggered with an anchor tag, like this: <a href="/bla/blabla" download>..</a> While Safari browser can handle this request and open a dialogue to handle the file, WKWebView treats this just as an ordinary link and does nothing with it. I want to be able to get the file handler dialogue that is normally there when using Safari. Right now there are 2 problems and I do not see an opening there yet: I can not detect a

Making WKWebView not share cookies with Safari in OS X

和自甴很熟 提交于 2019-12-06 02:56:15
问题 How do I make WKWebView not share cookies with Safari in OSX? I have a very simple app that I made as an experiment that displays a WKWebView and as far as I can see, it's picking up cookies from Safari, because in my custom app, I'm logged in in the same websites as Safari. I am currently creating the WKWebView instance like this: override func loadView() { self.webView = WKWebView() self.view = self.webView! } in an NSViewController I created. I also tried this: override func loadView() {

WKWebview getAllCookies crash in iOS 11.3

泪湿孤枕 提交于 2019-12-05 22:05:04
问题 We have recently migrated to WKWebview. We have added a listener for cookie change, to get the updated cookies and update our own store. - (void)cookiesDidChangeInCookieStore:(WKHTTPCookieStore *)cookieStore { [cookieStore getAllCookies:^(NSArray* cookies) { }]; } Once the controller is loaded, it calls cookiesDidChangeInCookieStore and crashes at "getAllCookies".But this crash happens only in TestFlight/Fabric build. Doesn't happen when i run the app directly on device from xcode (both in

How to check if WkWebView finish loading in Objective-C?

时光怂恿深爱的人放手 提交于 2019-12-05 08:29:22
问题 I want to load HTML pages using WkWebView and I want to show the page just after it's finished loading. As long as it's loading I would like to show an activity indicator on an empty View. I create two view a loadingView and a wkWebView. While the page is loading I add to VC as subview the loadingView and after I want to remove loadingView and add wkWebView. Here is my code: [self addSubview:_loadingView]; _wkWebView = [[WKWebView alloc] initWithFrame:self.frame]; _wkWebView.frame =

WKWebView Cookies

旧街凉风 提交于 2019-12-04 20:22:23
I'm using the below mentioned approach to set cookies in a WKWebview : Can I set the cookies to be used by a WKWebView? But the cookies that I have set are being duplicated in the AJAX calls. I mean they are being repeated twice. Here is the code snippet that I used: NSString *strURL = DASHBOARDURL; NSURL *url = [NSURL URLWithString:strURL]; NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init]; [request setURL:url]; NSMutableString *script = [[NSMutableString alloc] init]; NSMutableString *cookieString = [[NSMutableString alloc] init]; for (NSHTTPCookie *cookie in [

Get Javascript function response in iOS using Swift

◇◆丶佛笑我妖孽 提交于 2019-12-04 18:17:59
I am trying to figure out how to implement JavaScript functions inside my iOS app using swift platform . I have tried out the example code specified in the link https://tetontech.wordpress.com/2014/07/15/swift-to-javascript-and-javascript-to-swift-a-round-trip/ But i want in the same way like android is doing as specified in the link http://android-er.blogspot.in/2011/10/call-javascript-inside-webview-from.html Could you please help me out. Any help will deeply appriciated. If you are using WKWebView you can call javascript by using webView.evaluateJavaScript("YourJavaScript",completionHandler

How to autoscale the contents of a WKWebView?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-04 14:39:58
To autoscale a webpage inside a good old WebView in Swift, all I had to do was: var w:UIWebView w.scalesPageToFit=true I cannot find an equivalent method for a WKWebView, and webpages appear too big in my app. How can I autoscale the contents of a WKWebView? -I am using Xcode 7 and Swift Here is my solution: extension WKWebView { private struct key { static let scale = unsafeBitCast(Selector("scalesPageToFit"), UnsafePointer<Void>.self) } private var sourceOfUserScript: String { return "(function(){\n" + " var head = document.getElementsByTagName('head')[0];\n" + " var nodes = head

iOS WKWebView Handle File Download

早过忘川 提交于 2019-12-04 09:32:41
I am facing the following problem: In a web interface, file downloads are triggered with an anchor tag, like this: <a href="/bla/blabla" download>..</a> While Safari browser can handle this request and open a dialogue to handle the file, WKWebView treats this just as an ordinary link and does nothing with it. I want to be able to get the file handler dialogue that is normally there when using Safari. Right now there are 2 problems and I do not see an opening there yet: I can not detect a click on the element as it is treated just as a normal link. And I can not rely on the URL parameters to