// // PBWebViewController.m // IphoneBIMe // // Created by ZhangJF on 2023/2/7. // Copyright © 2023 ProBIM. All rights reserved. // #import "PBWebViewController.h" #import @interface PBWebViewController () @property (nonatomic, strong) WKWebView *wkWebView; @end @implementation PBWebViewController - (void)viewDidLoad { [super viewDidLoad]; self.view.backgroundColor = [UIColor whiteColor]; [self configNav]; [self.view addSubview:self.wkWebView]; [self loadData]; } - (void)loadData { NSURL *url = [NSURL URLWithString:self.jump_URL]; NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url]; [_wkWebView loadRequest:urlRequest]; } - (WKWebView *)wkWebView { if (!_wkWebView) { CGRect frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height); _wkWebView = [[WKWebView alloc] initWithFrame:frame]; _wkWebView.navigationDelegate = self; } return _wkWebView; } /// 页面加载完成之后调用 - (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation { } /// 页面加载失败时调用 - (void)webView:(WKWebView *)webView didFailNavigation:(WKNavigation *)navigation withError:(NSError *)error { } - (void)configNav { self.title = self.jump_Title; // UIButton *left_Button = [[UIButton alloc] init]; // [left_Button setTitle:@"back" forState:UIControlStateNormal]; // [left_Button setTitleColor:[UIColor colorWithRed: 21/ 255.0f green: 126/ 255.0f blue: 251/ 255.0f alpha:1.0] forState:(UIControlStateNormal)]; // [left_Button sizeToFit]; // [left_Button addTarget:self action:@selector(left_BarButtonItemAction) forControlEvents:UIControlEventTouchUpInside]; // UIBarButtonItem *left_BarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:left_Button]; // self.navigationItem.leftBarButtonItem = left_BarButtonItem; PBBackNavItem *backNav = [PBBackNavItem backNacItem]; backNav.title = @" "; [backNav addTarget:self action:@selector(left_BarButtonItemAction) forControlEvents:UIControlEventTouchUpInside]; UIBarButtonItem *backNavItem = [[UIBarButtonItem alloc] initWithCustomView:backNav]; self.navigationItem.leftBarButtonItem = backNavItem; self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:(UIBarButtonSystemItemRefresh) target:self action:@selector(right_BarButtonItemAction)]; } - (void)left_BarButtonItemAction { [self.navigationController popViewControllerAnimated:YES]; } - (void)right_BarButtonItemAction { [self.wkWebView reload]; } -(void)setJump_URL:(NSString *)jump_URL { _jump_URL = jump_URL; } -(void)setJump_Title:(NSString *)jump_Title { _jump_Title = jump_Title; } /* #pragma mark - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { // Get the new view controller using [segue destinationViewController]. // Pass the selected object to the new view controller. } */ @end