zjf
2023-03-06 392b76515f40376b6d36f40a114850ef63650384
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
//
//  PBWebViewController.m
//  IphoneBIMe
//
//  Created by ZhangJF on 2023/2/7.
//  Copyright © 2023 ProBIM. All rights reserved.
//
 
#import "PBWebViewController.h"
#import <WebKit/WebKit.h>
 
@interface PBWebViewController ()<WKNavigationDelegate, WKUIDelegate>
@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