簡體   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