我的代码在主线程的这一行崩溃了:
- > 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]
为什么会发生这种情况?如何解决此问题?