ChenYilong / ChenYilong/iOS11AdaptationTips

wkwebView加载mainBundle资源相关本地html 涉及html,css ,js等资源时奔溃

Open
#7 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
477
Forks
47
PR merge metrics
No merged PRs in 30d

Description

This problem is based on iOS11 beta,the details are:

the request:

NSString *htmlPath = [[NSBundle mainBundle] pathForResource:@"xxx" ofType:@"html"];
NSMutableURLRequest * request = [[NSMutableURLRequest alloc]initWithURL:[NSURL URLWithString:htmlPath]];
[self.webView loadRequest:request];

pragma mark - WKNavigationDelegate:

-(void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler{
decisionHandler(WKNavigationActionPolicyAllow);//奔溃地方 (crash)
}

-(void)webView:(WKWebView *)webView decidePolicyForNavigationResponse:(WKNavigationResponse *)navigationResponse decisionHandler:(void (^)(WKNavigationResponsePolicy))decisionHandler{
decisionHandler(WKNavigationResponsePolicyAllow);
}

情况说明:前面使用了loadRequest的请求方式,奔溃的地方在后面的代理decidePolicyForNavigationAction:使用WKNavigationActionPolicyAllow奔溃;在iOS11 beta以下正常.

经调试:采用loadHtmlWithString时不调用baseurl不会奔溃,但是肯定没有使用和加载数据

奔溃信息:Thread 1: signal SIGABRT

invalid mode 'kCFRunLoopCommonModes' provided to CFRunLoopRunSpecific - break on _CFRunLoopError_RunCalledWithInvalidMode to debug. This message will only appear once per execution.

libc++abi.dylib: terminate_handler unexpectedly threw an exception

Ask for your advice, thank you!!

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.