繁体   English   中英

iOS Webkit不在设备上工作,但在swift的模拟器上运行

[英]iOS Webkit not working on device, but works on simulator at swift

我在程序中使用htm文件进行一些工作。 在模拟器中我定义了这样的本地文件;

    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)

但当我将此应用程序发送到设备(iPhone 5s)

出现错误:file:///private/var/mobile/Containers/Bundle/Application/2E9F7BCA-D57E-4C47-8BBC-6CBF2FF2B2E1/Receteler.app/Akciger_odemi_Akut_Kalp_Yetmezligi.htm无法为'/'创建沙箱扩展名

这是我项目中的htm文件夹。 我从桌面添加了“向项目添加文件” 我在项目中的htm文件夹

你能帮我解释为什么我会犯错吗?

错误的导入文件或捆绑包的原因? 我不太了解objective-c所以如果你快速给我建议,我会非常高兴。

谢谢

您缺少WKWebView配置。 请在加载html文件之前添加以下行以解决问题。

var theConfiguration = WKWebViewConfiguration()

theWebView = WKWebView(frame:self.view.frame,configuration:theConfiguration)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM