圖片.png
解決方案:
info.plist ->添加字段App Transport Security Settings ->在該字典中添加鍵值A(chǔ)llow Arbitrary Loads蛙婴,并設(shè)置值為YES臼寄。
圖片.png
- 問題所在源碼
#import "DetailViewController.h"
#import "WebKit/WebKit.h"
@interface DetailViewController ()<WKNavigationDelegate>
@property (nonatomic, strong) WKWebView *webView;
@end
@implementation DetailViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.webView = [[WKWebView alloc] initWithFrame:self.view.frame];
[self.view addSubview:self.webView];
self.webView.navigationDelegate = self;
NSURL *url = [NSURL URLWithString:self.url];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[self.webView loadRequest:request];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark --實(shí)現(xiàn)WKNavigationDelegate委托方法
- (void)webView:(WKWebView *)webView didStartProvisionalNavigation:(WKNavigation *)navigation{
NSLog(@"開始加載");
}
- (void)webView:(WKWebView *)webView didCommitNavigation:(WKNavigation *)navigation{
NSLog(@"內(nèi)容開始返回");
}
- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation{
NSLog(@"加載完成");
}
- (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(WKNavigation *)navigation withError:(NSError *)error{
NSLog(@"加載失敗 error : %@", error.description);
}
@end