试图在UIWebView崩溃时加载本地PDF文件

时间:2015-10-18 06:12:06

标签: ios swift uiwebview

这看起来像是一段简单的代码,一直让我崩溃。它能够找到该文件并在日志中看到它,但每次都在webview.loadRequest请求行崩溃:

let kHelpFile = "DB_Help_Doc"

webView.delegate = self

webView.scalesPageToFit = true

self.view.addSubview(webView)


Scripts.log("WebViewVC >> URL is \(kHelpFile)")

if let url = NSBundle.mainBundle().URLForResource(kHelpFile, withExtension: "pdf") {

    Scripts.log("BUNDLE FOUND")
    Scripts.log("URL = \(url)")
    Scripts.log("PATH = \(url.path)")

    req = NSURLRequest(URL: NSURL(fileURLWithPath: url.path!))

    self.webView.loadRequest(req)

}
else {

    Scripts.log("BUNDLE NOT FOUND")

}

这是例外

  

的libc ++ abi.dylib`__cxa_throw:    - > 0x10e077c6b< + 0>:pushq%rbp       0x10e077c6c< + 1>:movq%rsp,%rbp       0x10e077c6f< + 4>:pushq%r15       0x10e077c71< + 6>:pushq%r14       0x10e077c73< + 8>:pushq%r12       0x10e077c75< + 10>:pushq%rbx       0x10e077c76< + 11>:movq%rdx,%r14       0x10e077c79< + 14>:movq%rsi,%r15       0x10e077c7c< + 17>:movq%rdi,%rbx       0x10e077c7f< + 20>:callq 0x10e07787d; __cxa_get_globals       0x10e077c84< + 25>:movq%rax,%r12       0x10e077c87< + 28>:callq 0x10e078220;的std :: get_unexpected()       0x10e077c8c< + 33>:movq%rax,-0x60(%rbx)       0x10e077c90< + 37>:callq 0x10e078258;的std :: get_terminate()       0x10e077c95< + 42>:movq%rax,-0x58(%rbx)       0x10e077c99< + 46>:movq%r15,-0x70(%rbx)       0x10e077c9d< + 50>:movq%r14,-0x68(%rbx)       0x10e077ca1< + 54>:leaq -0x20(%rbx),%r14       0x10e077ca5< + 58>:movabsq $ 0x434c4e47432b2b00,%rax       0x10e077caf< + 68>:movq%rax,-0x20(%rbx)       0x10e077cb3< + 72>:movq $ 0x1,-0x78(%rbx)       0x10e077cbb< + 80>:包含0x8(%r12)       0x10e077cc0< + 85>:leaq 0x1d(%rip),%rax; __cxxabiv1 :: exception_cleanup_func(_Unwind_Reason_Code,_Unwind_Exception *)       0x10e077cc7< + 92>:movq%rax,-0x18(%rbx)       0x10e077ccb< + 96>:movq%r14,%rdi       0x10e077cce< + 99>:callq 0x10e07ab3c;符号存根:_Unwind_RaiseException       0x10e077cd3< + 104>:movq%r14,%rdi       0x10e077cd6< + 107>:callq 0x10e077d08; __cxa_begin_catch       0x10e077cdb< + 112>:movq -0x58(%rbx),%rdi       0x10e077cdf< + 116>:callq 0x10e078266; std :: __ terminate(void(*)())

0 个答案:

没有答案