wkwebview

WKWebKit Mac OS NSPrintOperation

情到浓时终转凉″ 提交于 2020-03-18 04:33:11
问题 WebKit 1 exposed the WebFrameView where I could call a print operation. - (void)webView:(WebView *)sender printFrameView:(WebFrameView *)frameView { NSPrintOperation *printOperation = [frameView printOperationWithPrintInfo:[NSPrintInfo sharedPrintInfo]]; [printOperation runOperation]; } With WKWebKit API I can't seem to figure out how to perform a similar action or which view to grab for printing. All my efforts have come up with blank pages. 回答1: Amazingly, WKWebView still doesn't support

Taking screenshot of WKWebview with hardware accelerated content

冷暖自知 提交于 2020-03-17 11:41:24
问题 I am having serious trouble with taking screenshot of WKWebview content when there is hardware accelerated content (some specific casino games that are running inside iframe). So far I used the standard way of taking screenshot like everyone suggests: UIGraphicsBeginImageContextWithOptions(containerView.frame.size, true, 0.0) containerView.layer.render(in: UIGraphicsGetCurrentContext()!) //This line helps to fix view rendering for taking screenshot on older iOS devices containerView

How to force WKWebView to ignore hardware silent switch on iOS?

青春壹個敷衍的年華 提交于 2020-03-10 04:57:55
问题 The ask here is to play all kinds of web sounds regardless of the hardware silent switch , both muted and not muted devices must keep playing the sound in HTML pages while the app is foregrounded. The solution for deprecated UIWebView is quite easy let localWebView = UIWebView(frame: .zero) localWebView.allowsInlineMediaPlayback = true localWebView.mediaPlaybackRequiresUserAction = false How the same behavior can be achieved for WKWebView ? 回答1: Since I have a solution to this nontrivial

WKWebView兼容问题二:播放音效没声音

亡梦爱人 提交于 2020-03-09 14:19:32
问题描述: CocosCreator打包web-mobile,在WKWebView框架下运行,播放音效没声音。 解决方案: 在ViewController加入以下代码: configuration.allowsInlineMediaPlayback = YES; configuration.mediaPlaybackRequiresUserAction = false; #import "ViewController.h" #import <WebKit/WebKit.h> #define KMainWidth ([UIScreen mainScreen].bounds.size.width) #define KMainHeight ([UIScreen mainScreen].bounds.size.height) @interface ViewController ()<WKNavigationDelegate,WKUIDelegate,WKScriptMessageHandler> @property(nonatomic,strong)WKWebView *mainWebView; @property(nonatomic,strong)UIButton *alertButton; @end @implementation ViewController - (void

SwiftUI: WKWebView Cutting Off Page Content on macOS (NSViewRepresentable)

走远了吗. 提交于 2020-03-02 04:02:36
问题 I have a basic NSViewRepresentable implementation of WKWebView , for use with SwiftUI apps. The UIViewRepresentable equivalent works fine when run on iOS, but when running on macOS (natively, not Catalyst), the top content is always cut off. The amount lost always equals the size of parent views (such as the tab view) and their padding, which indicates that the web view keeps scaling its content to the window size, rather than the view size. For example, this page: ...should be as follows (as

SwiftUI WKWebView content height issue

允我心安 提交于 2020-02-28 15:10:52
问题 It's been a week I'm stuck with this issue where I have my custom WKWebView with UIViewRepresentable struct Webview : UIViewRepresentable { var webview: WKWebView? init() { self.webview = WKWebView() } class Coordinator: NSObject, WKNavigationDelegate { var parent: Webview init(_ parent: Webview) { self.parent = parent } func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) { print("Loading finished -- Delegate") webView.evaluateJavaScript("document.documentElement

SwiftUI WKWebView detect url changing

生来就可爱ヽ(ⅴ<●) 提交于 2020-02-25 04:25:10
问题 I'm a swift learner. I work with SwiftUI which is a struct, I have to implement a WKWebView and in that, a url is changing dynamically. I have to catch these changing urls, but solutions I have tried are not working. For example: https://stackoverflow.com/a/48273950/10088243 I tried this code block but it is not working and it gives me some compiler errors: import SwiftUI import WebKit struct ContentView: UIViewRepresentable, WKNavigationDelegate { let request = URLRequest(url: URL(string:

How to intercept a WKWebView request to detect which local resource files (css, js, png, …) load together with a HTML file?

二次信任 提交于 2020-02-22 04:17:12
问题 I have a HTML file which contains local resource files such as css, js and png files inside its content. These local resource files are in zip format. My app use WKWebView to display this html file. I want to find a solution to intercept the web view request to detect which local resource files are load together with this html file -> then unzip them if they are still zip format. My HTML data content contains thousands of these local resource file so I can't unzip all of them before display

iframe content from external source not loading in local HTML file on iOS

家住魔仙堡 提交于 2020-02-21 13:04:16
问题 I created a local HTML file in my iOS app written in swift. The HTML file is loaded into a WKWebView as follows: let url = Bundle(identifier: myIdentifier).url(forResource: "localHtmlFile", withExtension: "html") let htmlFormatString = try String(contentsOf: url) loadHTMLString(string: htmlFormatString, baseURL: nil) The HTML page contains an iframe which I expect to load an external page: <div>Test</div> <iframe src="https://www.somepage.com"></iframe> The local HTML file is loaded

iframe content from external source not loading in local HTML file on iOS

╄→гoц情女王★ 提交于 2020-02-21 13:03:30
问题 I created a local HTML file in my iOS app written in swift. The HTML file is loaded into a WKWebView as follows: let url = Bundle(identifier: myIdentifier).url(forResource: "localHtmlFile", withExtension: "html") let htmlFormatString = try String(contentsOf: url) loadHTMLString(string: htmlFormatString, baseURL: nil) The HTML page contains an iframe which I expect to load an external page: <div>Test</div> <iframe src="https://www.somepage.com"></iframe> The local HTML file is loaded