//使用UIWebView 有些网页加载卡顿 内存还飙升的特别厉害 最后改成WKWebView就可以了
适配 8.0 以上
#import "AdvertiseWebController.h"
#import "MBProgressHUD.h"
#import <WebKit/WebKit.h>
@interface AdvertiseWebController ()<WKNavigationDelegate>
@property (strong , nonatomic) WKWebView *webView;
@end
@implementation AdvertiseWebController
- (void)viewDidLoad {
[super viewDidLoad];
if ([self.urlStr isEqualToString:@""] ) {
[MBProgressHUD autoShowAndHideWithMessage:@"信息有误"];
}
self.webView = [[WKWebView alloc]initWithFrame:CGRectMake(0, 64, kScreenWidth, kScreenHeight - 64)];
self.webView.navigationDelegate = self;
[self.webView loadRequest:[NSURLRequest requestWithURL:[[NSURL alloc] initWithString:self.urlStr]]];
[self.view addSubview:self.webView];
}
-(void)webView:(WKWebView *)webView didStartProvisionalNavigation:(WKNavigation *)navigation
{
[MBProgressHUD showMessage:@"加载中..."];
}
-(void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation
{
[MBProgressHUD hideMessage];
}
-(void)webView:(WKWebView *)webView didFailNavigation:(WKNavigation *)navigation withError:(NSError *)error
{
[MBProgressHUD hideMessage];
}
@end