简体   繁体   English

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

[英]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 我从桌面添加了“向项目添加文件” 我在项目中的htm文件夹

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.

相关问题 Facebook 登录 Swift 在设备上不起作用(但在 IOS 模拟器上起作用) - Facebook Login Swift don't works On Device (But do on IOS Simulator) 在iOS模拟器上可以使用,但在iOS设备上不能使用吗? - Works on iOS Simulator but not on iOS device? wsdl2objc在ios 6.0模拟器上不起作用,但在ios 5设备上起作用 - wsdl2objc is not working on ios 6.0 simulator but works on ios 5 device writeToFile在模拟器上工作,而在使用iOS Swift的设备上不工作 - writeToFile is working on simulator and not working on device using ios swift NumberFormatter 适用于模拟器,但不适用于设备 swift - NumberFormatter works on simulator but not on device swift Firebase Cloud消息可在模拟器中使用,但不能在IOS设备上使用 - Firebase Cloud message works in simulator but not working on IOS device iOS应用程序可在模拟器上运行,但不能在设备上运行 - IOS application works on the simulator but not on the device 字体适用于模拟器但不适用于 iOS 设备 - Font works on Simulator but not iOS device GetViewForHeader可在模拟器中工作,但不能在设备上工作 - GetViewForHeader works in the simulator but not working on the device ECGraph不在设备上工作,但在模拟器上工作 - ECGraph not working on device, but works on simulator
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM