iOS Webkit无法在设备上运行,但可以在模拟器上快速运行 [英] iOS Webkit not working on device, but works on simulator at swift

查看:59
本文介绍了iOS Webkit无法在设备上运行,但可以在模拟器上快速运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将htm文件用于程序中的某些工作.在模拟器中,我这样定义了本地文件;

i use htm file for some work in program. 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)

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

but when i send this app to device (iPhone 5s)

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

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 '/'

这是我在项目上的htm文件文件夹.我从桌面添加了它们将文件添加到项目"

this is my htm files folders on project. i added them "add files to project" from desktop

您能帮我为什么我出错吗?

can you help me why i take an error ?

错误的导入文件或关于捆绑?我不太了解Objective-C,因此,如果您迅速给我建议,我会非常高兴.

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.

谢谢

推荐答案

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

You are missing WKWebView configuration. Please add the following lines before loading your html file to fix the problem.

var theConfiguration = WKWebViewConfiguration()

var theConfiguration = WKWebViewConfiguration()

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

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

这篇关于iOS Webkit无法在设备上运行,但可以在模拟器上快速运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆