我在程序中使用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)时
出现错误: 文件:///private/var/mobile/Containers/Bundle/Application/2E9F7BCA-D57E-4C47-8BBC-6CBF2FF2B2E1/Receteler.app/Akciger_odemi_Akut_Kalp_Yetmezligi.htm 无法为' /'
创建沙盒扩展程序这是我项目中的htm文件夹。我添加了他们"将文件添加到项目"来自桌面
错误导入文件的原因或 关于捆绑? 我不太了解objective-c所以如果你快速给我建议,我会非常高兴。
谢谢
答案 0 :(得分:3)
您缺少WKWebView配置。请在加载html文件之前添加以下行以解决问题。
var theConfiguration = WKWebViewConfiguration()
theWebView = WKWebView(frame:self.view.frame,configuration:theConfiguration)