wkwebview

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

烈酒焚心 提交于 2020-02-21 12:59:46
问题 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

How to load local directory inside iframe in iOS Swift?

∥☆過路亽.° 提交于 2020-02-16 10:40:11
问题 In loadHTMLStringImage function i have been loaded index.html let htmlPath = Bundle.main.path(forResource: "index", ofType: "html") let htmlUrl = URL(fileURLWithPath: htmlPath!, isDirectory: false) self.webView.loadFileURL(htmlUrl, allowingReadAccessTo: htmlUrl) After loading I have been checking md5 string. From the md5 zip file, I am unzipping to the local directory and got the local file directory URL. And passing the local directory URL to iframe src. But it shows an empty screen. In

uni app video、视频播放开发

隐身守侯 提交于 2020-02-12 09:18:35
视频播放有3种解决方案,使用HTML5的自带video、从HBuilder9.1.3起新增的plus.video的原生视频播放,以及使用Native.js。 HTML5自带video标签,可以播放符合HTML5规范的视频格式。 注意不含flv、ra等三方商业公司的规范格式。 HTML5的video在Android上有较多浏览器兼容性问题,这里有篇网友分享的经典文章讲述了HTML5 video的使用注意,强烈推荐观看。 http://ask.dcloud.net.cn/article/569 注意事项,Android上使用video标签播放视频时,务必打开硬件加速,否则只有声音没有画面。 HBuilder8.8.4以前的版本,在Android5的部分rom上是默认关闭硬件加速的,此时需强制打开硬件加速。创建webview时style里有个hardwareAccelerated参数,设置为true。 硬件加速的详解参考文档 http://ask.dcloud.net.cn/article/55 视频全屏播放时有时不能自动横屏最大化,参考 http://ask.dcloud.net.cn/article/1077 HTML5自带video,如果想实现手势拖动进度,这里有篇参考文章 http://ask.dcloud.net.cn/article/13263 ,但受限于HTML5的性能

iOS9 WKWebView 释放时闪退

匆匆过客 提交于 2020-02-05 03:51:55
0.背景描述 项目里发现,在iOS9系统上打开网页后关闭时,应用会闪退,调试得到日志: 2019-12-18 18:25:37.931 xxx[18873:407888] *** -[XXWebViewController retain]: message sent to deallocated instance 0x7ffefd68a740 1.问题查找 依次排查了下页面中使用WKWebView的属性,最后发现只要设置了 WKWebView.scrollView.delegate 属性,在页面关闭,WKWebView对象释放时就会闪退。 2.解决办法 只需要在controller的dealloc方法中将 WKWebView.scrollView.delegate 置为nil即可。 来源: CSDN 作者: 奇风 链接: https://blog.csdn.net/jhq1990/article/details/103602549

UIAlertView is deprecated and unavailable for UIScene based applications, please use UIAlertController

﹥>﹥吖頭↗ 提交于 2020-02-02 09:47:04
问题 I'm new to Swift and I'm getting this Error. I don't get it because I don't use any type of alert in my code. Here is my ViewController: import UIKit import WebKit class ViewController: UIViewController{ @IBOutlet weak var webView: WKWebView! override func viewDidLoad() { super.viewDidLoad() let url = URL(string: "https://www.google.com/maps")! webView.load(URLRequest(url: url)) } } I only want to use WKWebView in my app and use the location. I already added

How to support Zoom like Safari with WKWebView on macOS

百般思念 提交于 2020-02-01 04:51:26
问题 In Safari the user can enlarge the content by using the Zoom commands, like Command +. This enlarges not only the content, including font size, but it also adjusts the content to remain between the window margins. I want to achieve the same feature with WKWebView on macOS, but I don't know how to do that when using the loadRequest() command on the web view control. I have tried the following, without much success: Inject javascript like "document.getElementsByTagName('body')[0].style

WKWebview - Complex communication between Javascript & native code

无人久伴 提交于 2020-01-28 03:20:51
问题 In WKWebView we can call ObjectiveC/swift code using webkit message handlers eg: webkit.messageHandlers.<handler>.pushMessage(message) It works well for simple javascript functions without parameters. But; Is it possible to call native code with JS callback function as parameters? Is it possible to return a value to JS function from native code? 回答1: Unfortunately I couldn't find a native solution. But the following workaround solved my problem Use javascript promises & you can call the

WKWebview - Complex communication between Javascript & native code

混江龙づ霸主 提交于 2020-01-28 03:18:10
问题 In WKWebView we can call ObjectiveC/swift code using webkit message handlers eg: webkit.messageHandlers.<handler>.pushMessage(message) It works well for simple javascript functions without parameters. But; Is it possible to call native code with JS callback function as parameters? Is it possible to return a value to JS function from native code? 回答1: Unfortunately I couldn't find a native solution. But the following workaround solved my problem Use javascript promises & you can call the

Unable to load audio files via XMLHttpRequest using WKWebView

随声附和 提交于 2020-01-25 23:43:06
问题 I enjoy making old school arcade games using HTML5 Canvas and JS. I've been doing it for years and am probably a bit set in my ways. The games work great in Chrome / Safari on all modern devices. I figured I should try wrapping a game up using PhoneGap to see how it might perform as an app on the iOS AppStore. The game was pretty choppy although the audio played great. I read about the performance boost of WKWebView over the default UIWebView so added that to my config.xml. The game played

Cannot load local html file into WKWebView on ios device (not simulator) [duplicate]

孤街浪徒 提交于 2020-01-25 08:17:49
问题 This question already has answers here : Load local web files & resources in WKWebView (3 answers) Closed 3 months ago . I'm having troubles with the following code. It's supposed to load a local HTML file into a WKWebView. It works fine on any simulator I've tried (ios 12 / ios 13). For a reason I do not understand yet, it does not work on device. Instead, I get a blank screen. Debugging the webview with the Safari debugger shows that the page is "about:blank". It did not load my file... Why