WebView loadRequest方法因EXC_BAD_ACCESS崩溃(代码= 1,地址= 0x10)

时间:2017-10-11 15:52:15

标签: ios objective-c xcode

我的代码在主线程的这一行崩溃了:

- > 0x194324c1c< + 40>:ldr w8,[x0,#0x10]

以下是我加载WebView的方法:(请注意,所有这些代码都在我的viewDidLoad方法中)

NSString *pdfPath = [[NSBundle mainBundle] pathForResource:@"BOR" ofType:@"pdf"];
NSFileManager *fileManager = [NSFileManager defaultManager];

WKWebViewConfiguration *theConfiguration = [[WKWebViewConfiguration alloc] init];
WKWebView *webView = [[WKWebView alloc] initWithFrame:self.view.frame configuration:theConfiguration];
webView.navigationDelegate = self;
[self.view addSubview:webView];

[UIView setAnimationsEnabled:NO];

if ([fileManager fileExistsAtPath:pdfPath]) {
    NSLog(@"File exists!");
    NSURL *fileURL = [[NSURL alloc] initWithString:pdfPath];
    NSURLRequest *fileRequest = [NSURLRequest requestWithURL:fileURL cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData timeoutInterval:30];
    dispatch_async(dispatch_get_main_queue(), ^{
        [webView loadRequest:fileRequest];
    });
}
else {
    NSLog(@"File does not exist");
}

我的代码一旦执行就会崩溃:

[webView loadRequest:fileRequest]

为什么会发生这种情况?如何解决此问题?

0 个答案:

没有答案