[英]iOS Webkit not working on device, but works on simulator at swift
i use htm file for some work in program. 我在程序中使用htm文件进行一些工作。 in simulator i defined local file like this ; 在模拟器中我定义了这样的本地文件;
var a = dic["acil_adi"]?.asString()
var path = NSBundle.mainBundle().pathForResource(a,
ofType: ".htm")
var url = NSURL(fileURLWithPath:path!)
var request = NSURLRequest(URL:url)
println("\(url)")
var theWebView:WKWebView = WKWebView(frame:self.view.frame)
theWebView.loadRequest(request)
self.view.addSubview(theWebView)
but when i send this app to device (iPhone 5s) 但当我将此应用程序发送到设备(iPhone 5s)
error appears : file:///private/var/mobile/Containers/Bundle/Application/2E9F7BCA-D57E-4C47-8BBC-6CBF2FF2B2E1/Receteler.app/Akciger_odemi_Akut_Kalp_Yetmezligi.htm Could not create a sandbox extension for '/' 出现错误:file:///private/var/mobile/Containers/Bundle/Application/2E9F7BCA-D57E-4C47-8BBC-6CBF2FF2B2E1/Receteler.app/Akciger_odemi_Akut_Kalp_Yetmezligi.htm无法为'/'创建沙箱扩展名
this is my htm files folders on project. 这是我项目中的htm文件夹。 i added them "add files to project" from desktop 我从桌面添加了“向项目添加文件”
can you help me why i take an error ? 你能帮我解释为什么我会犯错吗?
cause of wrong import file or about bundle ? 错误的导入文件或捆绑包的原因? i don't know objective-c very well so if you give me advice with swift i will be very happy. 我不太了解objective-c所以如果你快速给我建议,我会非常高兴。
thank you 谢谢
You are missing WKWebView configuration. 您缺少WKWebView配置。 Please add the following lines before loading your html file to fix the problem. 请在加载html文件之前添加以下行以解决问题。
var theConfiguration = WKWebViewConfiguration() var theConfiguration = WKWebViewConfiguration()
theWebView = WKWebView(frame:self.view.frame, configuration: theConfiguration) theWebView = WKWebView(frame:self.view.frame,configuration:theConfiguration)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.