Authored by 孙凯

Merge commit '12ab4483' into feature/pictureClick

... ... @@ -61,15 +61,26 @@
if ([weakIf respondsToSelector:@selector(nativeActionDidTriggerEventWithUserInfo:completion:)]) {
[weakIf nativeActionDidTriggerEventWithUserInfo:info
completion:^(NSDictionary *callbackInfo, BOOL result) {
completion:^(id callbackInfo, BOOL result) {
CDVPluginResult *pluginResult;
CDVCommandStatus cmdStatus = CDVCommandStatus_ERROR;
if (result) {
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:callbackInfo];
cmdStatus = CDVCommandStatus_OK;
} else {
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:callbackInfo];
cmdStatus = CDVCommandStatus_ERROR;
}
if ([callbackInfo isKindOfClass:[NSString class]]) {
pluginResult = [CDVPluginResult resultWithStatus:cmdStatus messageAsString:(NSString *)callbackInfo];
}else if ([callbackInfo isKindOfClass:[NSDictionary class]]){
pluginResult = [CDVPluginResult resultWithStatus:cmdStatus
messageAsDictionary:(NSDictionary *)callbackInfo];
}else if ([callbackInfo isKindOfClass:[NSArray class]]){
pluginResult = [CDVPluginResult resultWithStatus:cmdStatus
messageAsMultipart:(NSArray *)callbackInfo];
}
[weakSelf.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}];
} else {
... ...
... ... @@ -28,6 +28,6 @@
* @param userInfo
* @param completion 执行结果
*/
- (void)nativeActionDidTriggerEventWithUserInfo:(NSDictionary *)userInfo completion:(void (^) (NSDictionary *, BOOL))completion;
- (void)nativeActionDidTriggerEventWithUserInfo:(NSDictionary *)userInfo completion:(void (^) (id, BOOL))completion;
@end
... ...
... ... @@ -120,6 +120,13 @@
}
}
- (void)loadHTMLString:(NSString *)html baseURL:(nullable NSURL *)baseURL
{
if (self.isLoaded) {
[self.webViewController loadHTMLString:html baseURL:baseURL];
}
}
- (void)setProgressBarColor:(UIColor *)color
{
[self.webViewController setProgressBarColor:color];
... ...
... ... @@ -28,6 +28,8 @@
* @param html 网页内容
*/
- (void)loadHTMLString:(NSString * _Nonnull)html;
- (void)loadHTMLString:(NSString *)html baseURL:(nullable NSURL *)baseURL;
/**
* 设置进度条的颜色
*
... ... @@ -158,7 +160,16 @@
@since 1.1.0
*/
- (void)didGetMessageFromWeb:(NSDictionary * _Nonnull)params completion:(void (^ _Nonnull) (NSDictionary * _Nullable, BOOL))completion;
- (void)didGetMessageFromWeb:(NSDictionary * _Nonnull)params completion:(void (^ _Nonnull) (id _Nullable, BOOL))completion;
/**
由于shouldStartLoadWithRequest这个代理方法不适合对外暴露,此代理将暴露webview拦截到的请求
@param webView UIWebView
@param request 网页请求
@param navigationType 请求类型
*/
- (void)webView:(UIWebView *)webView didCatchRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType;
@required
@end
... ...
... ... @@ -218,6 +218,11 @@ static float kprogressViewRadius = 2.0f;
[self.webView loadHTMLString:html baseURL:[[NSBundle mainBundle] bundleURL]];
}
- (void)loadHTMLString:(NSString *)html baseURL:(nullable NSURL *)baseURL
{
[self.webView loadHTMLString:html baseURL:baseURL];
}
- (void)setProgressBarColor:(UIColor *)color
{
if (self.progressBar) {
... ... @@ -354,6 +359,10 @@ static float kprogressViewRadius = 2.0f;
return NO;
}
if ([self.delegate respondsToSelector:@selector(webView:didCatchRequest:navigationType:)]) {
[self.delegate webView:theWebView didCatchRequest:request navigationType:navigationType];
}
BOOL b = [super webView:theWebView shouldStartLoadWithRequest:request navigationType:navigationType];
if (self.delegate && [self.delegate respondsToSelector:@selector(webView:shouldStartLoadWithRequest:navigationType:)]) {
... ... @@ -394,7 +403,7 @@ static float kprogressViewRadius = 2.0f;
return NO;
}
- (void)nativeActionDidTriggerEventWithUserInfo:(NSDictionary *)userInfo completion:(void (^)(NSDictionary *, BOOL))completion {
- (void)nativeActionDidTriggerEventWithUserInfo:(NSDictionary *)userInfo completion:(void (^)(id, BOOL))completion {
dispatch_async(dispatch_get_main_queue(), ^{
if ([self.delegate respondsToSelector:@selector(didGetMessageFromWeb:completion:)]) {
... ...