我有一個本地的HTML
(靜態內容和無鏈接內部)文件,需要在Web視圖中加載。我已經使用UIWebView
加載它,但升級到Swift 2.0和Xcode 7後,現有的實現在presentViewController這一行崩潰,我們嘗試呈現內部具有web視圖但以前工作正常的視圖控制器。這似乎是因爲WebKit
介紹的問題,但它不應該影響現有的執行權。所以任何人都可以幫助我,或者建議我走最好的路? 該項目的目標是iOS 8及以上版本(僅iPad)。 這是正在無法在Swift 2.0和Xcode 7中的WebView中加載本地HTML文件
let path = NSBundle.mainBundle().URLForResource("index", withExtension: "html")
let prepareRequest = NSURLRequest(URL: path!)
self.webView.loadRequest(prepareRequest)
感謝
Crash Report
1 0x8707b09 StartWebThread()
2 0x524d6b0 __pthread_once_handler
3 0x523eebe _os_once
4 0x524d65f pthread_once
5 0x870789e WebThreadEnable
6 0x75ce14a +[WebView(WebPrivate) enableWebThread]
7 0x75cad90 WebKitInitialize
8 0x2822a30 ___UIApplicationLoadWebKit_block_invoke
9 0x4f0abef _dispatch_client_callout
10 0x4ef4a92 dispatch_once_f
11 0x4ef4922 dispatch_once
12 0x2822940 _UIApplicationLoadWebKit
13 0x4083461 _class_initialize
14 0x408bfe5 lookUpImpOrForward
15 0x408be8d _class_lookupMethodAndLoadCache3
16 0x409612f objc_msgSend
17 0x2cef77a UINibDecoderDecodeObjectForValue
18 0x2cef9b0 UINibDecoderDecodeObjectForValue
19 0x2cef4c3 -[UINibDecoder decodeObjectForKey:]
20 0x289480c -[UIView initWithCoder:]
21 0x28be337 -[UIScrollView initWithCoder:]
22 0x2cef7ae UINibDecoderDecodeObjectForValue
23 0x2cef4c3 -[UINibDecoder decodeObjectForKey:]
24 0x2b6cbca -[UIRuntimeConnection initWithCoder:]
25 0x2cef7ae UINibDecoderDecodeObjectForValue
26 0x2cef9b0 UINibDecoderDecodeObjectForValue
27 0x2cef4c3 -[UINibDecoder decodeObjectForKey:]
28 0x2b6be80 -[UINib instantiateWithOwner:options:]
29 0x29860d4 -[UIViewController _loadViewFromNibNamed:bundle:]
30 0x298686b -[UIViewController loadView]
31 0x2986a9f -[UIViewController loadViewIfRequired]
是的,我已經添加了plist中的代碼,仍然我得到崩潰。在主要問題中添加了崩潰報告 – Sandy
您不需要'NSAllowsArbitraryLoads'來加載文件。它只與網絡請求有關。 –