YHExplorerWebViewDelegate.h
4.38 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
//
// YHExplorerWebViewDelegate.h
// ALWlibwebp
//
// Created by 孟顺 on 2019/3/5.
//
#import <Foundation/Foundation.h>
#import "Cordova.h"
@class YHExplorerViewController;
@protocol YHLinkParserDelegate;
@protocol YHExplorerWebViewDelegate <NSObject>
@optional
- (void)yhExplorer_webViewDidStartLoad:(nonnull YHExplorerViewController *)explorer;
- (void)yhExplorer_webViewDidFinishLoad:(nonnull YHExplorerViewController *)explorer;
- (void)yhExplorer_webView:(nonnull YHExplorerViewController *)explorer didFailLoadWithError:(nullable NSError *)error;
- (BOOL)yhExplorer_webView:(nonnull YHExplorerViewController *)explorer shouldStartLoadWithRequest:(nullable NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType;
- (void)yhExplorer_webViewWebContentProcessDidTerminate:(id)webView;
@end
#pragma mark - Protocol:YHExplorerDelegate
@protocol YHExplorerDelegate <YHExplorerWebViewDelegate>
@optional
/**
* 获取页面的title
*
* @param title 页面的title
*/
- (void)pageTitleUpdated:(NSString * _Nullable)title;
/**
* webView探测到含有指定参数的回调
*
* @param params 参数
*/
- (void)explorerDidDetectParameters:(NSDictionary * _Nonnull)params __attribute__((deprecated("Use `- explorer:didDetectParameters:` instead.")));
/**
@brief 获取页面的title
@param explorer explorer对象
@param params 参数
@since 1.1.0
*/
- (void)explorer:(YHExplorerViewController * _Nonnull)explorer didDetectParameters:(NSDictionary * _Nonnull)params;
/**
@brief 将要加载请求前的回调 iOS系统>=11&&使用的wkwebview 则不会回调 此时使用wkwebviewDecidePolicyForNavigationActionWithUrl:
@param request 请求
@since 6.8.9
*/
- (void)explorerWillLoadRequest:(NSMutableURLRequest * _Nonnull)request;
/**
当wkwebview加载 一个url 会询问客户端是否应该加载时的 回调, 当且仅当iOS11及其以上的版本才可以使用
*/
- (void)wkwebviewDecidePolicyForNavigationActionWithUrl:(NSURL *)url API_AVAILABLE(ios(11.0));
/**
@brief 补充userAgent
@return 需要添加的UserAgent
@since 1.1.0
*/
- (NSString * _Nullable)extraUserAgent;
/**
@brief 点击图片事件
注:需要开启 `YHExplorerView`属性`enablePictureTapGesture`
@param explorer explorer对象
@param params 图片的一些信息
@since 1.1.3
*/
- (void)explorer:(YHExplorerViewController * _Nonnull)explorer didClickPicture:(NSDictionary * _Nonnull)pictureInfo;
#pragma mark Native
/**
@brief H5端触发Native事件
@param params 事件参数
@param completion 处理完后的回调(务必回调!!!)
@since 1.1.0
*/
- (void)didGetMessageFromWeb:(NSDictionary * _Nonnull)params completion:(void (^) (id _Nullable, BOOL))completion;
@required
@end
@protocol YHExplorerWebViewActionProtocol <NSObject>
@optional
- (nullable UIScrollView *)scrollView;
- (nullable NSURL *)requestURL;
- (BOOL)isLoading;
- (BOOL)canGoBack;
- (BOOL)canGoForward;
- (nullable id)goBack;
- (nullable id)goForward;
- (nullable id)reload;
- (nullable id)reloadFromOrigin;
- (void)stopLoading;
@property (nonatomic) BOOL scalesPageToFit;
- (void)evaluateJavaScript:(nonnull NSString *)javaScriptString completionHandler:(void (^ __nullable)(__nullable id, NSError * __nullable error))completionHandler;
- (nullable NSString *)stringByEvaluatingJavaScriptFromString:(nonnull NSString *)javaScriptString;
- (void)yh_setScrollEnabled:(BOOL)enabled;
@end
#pragma mark - Protocol:YHExplorer
@protocol YHExplorer <YHExplorerWebViewActionProtocol>
/**
* 加载url
*
* @param url 地址
*/
- (void)loadWebUrl:(NSString * _Nonnull)url;
/**
* 加载URL
*
* @param URL
*/
- (void)loadURL:(NSURL * _Nonnull)URL;
/**
* 加载html内容
*
* @param html 网页内容
*/
- (void)loadHTMLString:(NSString * _Nonnull)html;
/**
* 加载html内容
*
* @param html 网页内容
* @param baseURL URL
*/
- (void)loadHTMLString:(NSString * _Nonnull)html baseURL:(NSURL * __nullable)baseURL;
/**
* 设置进度条的颜色
*
* @param color 颜色
*/
- (void)setProgressBarColor:(UIColor * _Nonnull)color;
@optional
/**
* 注册一个链接解析器
*
* @param parser 链接解析器
*/
- (void)registerLinkParser:(id <YHLinkParserDelegate> _Nonnull)parser;
/**
* 禁用链接解析
*
* @param parser 链接解析器
*/
- (void)unRegisterLinkParser:(id <YHLinkParserDelegate> _Nonnull)parser;
/**
* 移除滚动条
*/
- (void)removeProgress;
@end