BUWebViewDefine.h
2.42 KB
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
92
93
94
95
96
97
98
99
100
101
102
103
//
// BUWebViewDefine.h
// BURexxar
//
// Created by muhuai on 2017/5/17.
// Copyright © 2017年 muhuai. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "BURexxarEngine.h"
#import "BUJSInjector.h"
typedef NS_ENUM(NSInteger, BUWebViewNavigationType) {
BUWebViewNavigationTypeLinkClicked,
BUWebViewNavigationTypeFormSubmitted,
BUWebViewNavigationTypeBackForward,
BUWebViewNavigationTypeReload,
BUWebViewNavigationTypeFormResubmitted,
BUWebViewNavigationTypeOther
};
@protocol BUWebView;
@protocol BUWebViewDelegate <NSObject>
@optional
- (BOOL)webView:(UIView<BUWebView> *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(BUWebViewNavigationType)navigationType;
- (void)webViewDidStartLoad:(UIView<BUWebView> *)webView;
- (void)webViewDidFinishLoad:(UIView<BUWebView> *)webView;
- (void)webView:(UIView<BUWebView> *)webView didFailLoadWithError:(NSError *)error;
- (void)webViewWebContentProcessDidTerminate:(UIView<BUWebView> *)webView API_AVAILABLE(macosx(10.11), ios(9.0));
//二方页面有 domReady回调
- (void)webViewDomReady:(UIView<BUWebView> *)webView;
@end
/**
BUWKWebView 都会实现此协议, 用来对平两个容器之间API的差异
*/
@protocol BUWebView <BURexxarEngine>
@property (nonatomic, strong ,readonly) UIScrollView *ttr_scrollView;
/**
JS脚本注入器 使用说明见:BUJSInjector.h
*/
@property (nonatomic, strong, readonly) BUJSInjector *ttr_injector;
#pragma mark - Loading Content
- (void)ttr_loadRequest:(NSURLRequest *)request;
- (void)ttr_loadHTMLString:(NSString *)string baseURL:(NSURL *)baseURL;
/**
WK下特有的方法
@param URL 本地文件URL, 注意需要为file://
@param readAccessURL WK下可以指定获取一个本地目录的权限
*/
- (void)ttr_loadFileURL:(NSURL *)URL allowingReadAccessToURL:(NSURL *)readAccessURL;
- (void)ttr_stopLoading;
- (void)ttr_reload;
#pragma mark - Moving Back and Forward
- (BOOL)ttr_canGoBack;
- (BOOL)ttr_canGoForward;
- (void)ttr_goBack;
- (void)ttr_goForward;
#pragma mark - Multi Delegate
/**
BUWKWebView内部实现成多路代理, 按注册的顺序来依次询问.
@param delegate webview代理
*/
- (void)ttr_addDelegate:(id<BUWebViewDelegate>)delegate;
/**
移除指定代理
@param delegate 需要移除的代理
*/
- (void)ttr_removeDelegate:(id<BUWebViewDelegate>)delegate;
/**
移除所有代理
*/
- (void)ttr_removeAllDelegate;
@end