WKWebView - 当组件发生故障时未调用didFailProvisionalNavigation

时间:2016-12-15 12:02:57

标签: ios objective-c uiwebview wkwebview

我在WKWebView中加载的页面组件失败时尝试记录错误,但未调用didFailProvisionalNavigation

我从我的网页中删除了 css 文件以进行测试,但没有结果。

当我在Google Chrome上加载页面时,我可以找到丢失的文件

enter image description here

WKWebView初始化为:

@interface MyWebView : UIViewController <WKNavigationDelegate>
@property(strong,nonatomic) WKWebView *loginWebView;
@end

.m文件

@implementation MyWebView

- (void) initWebView {

    // Set and Load the WebView
    self.webView = [[WKWebView alloc] initWithFrame:self.view.frame];
    self.webView.navigationDelegate = self;
    [self.webView loadRequest:request];
    [self.view addSubview:self.webView];
}

然后我实现了以下方法:

webView:decidePolicyForNavigationAction:decisionHandler:
webView:didStartProvisionalNavigation:
webView:didFinishNavigation:
webView:didFailNavigation:withError:
webView:didFailProvisionalNavigation:withError:

调用前三个方法,但didFailNavigationdidFailProvisionalNavigation都不会被调用

查看我们didFailProvisionalNavigation的{​​{3}}

  

在Web视图加载内容时发生错误时调用。

嗯,内容失败了(css文件)并且没有调用该方法,我该怎么做?

PS:我也尝试过使用UIWebView

1 个答案:

答案 0 :(得分:1)

#include <stdio.h>

int main()

{

char name[90];
int age;
char letter;

printf("What is your name?\n");
scanf("%s", &name);

printf("How old are you?\n");
scanf("%d", &age);

printf("Where are you from?\n");
scanf("%s", &letter);

printf("Your name is %s, You are %d, You are from %s\n");
return 0;}

这有效!