I created an WKWebView, but it can not load "https://www.baidu.com" and also it keeps calling decidePolicyForNavigationAction function it works well for other website @interface ViewController()<WKNavigationDelegate> @property (nonatomic, strong) WKWebView* webview; @end
@implementation ViewController
-
(void)viewDidLoad { [super viewDidLoad];
// Do any additional setup after loading the view. self.webview = [[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 500, 500)]; [self.view addSubview:self.webview]; self.webview.navigationDelegate = self;
NSURL* url = [NSURL URLWithString:@"https://www.baidu.com"]; NSURLRequest* request = [NSURLRequest requestWithURL:url]; [self.webview loadRequest:request];
// [self.webview reload]; }
-
(void)setRepresentedObject:(id)representedObject { [super setRepresentedObject:representedObject];
// Update the view, if already loaded.
}
- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction preferences:(WKWebpagePreferences *)preferences decisionHandler:(void (^)(WKNavigationActionPolicy, WKWebpagePreferences *))decisionHandler{ decisionHandler(WKNavigationActionPolicyAllow, preferences);
}