我们这边和h5商量好传递一个结构体参数过去,然后由于解析的问题,导致我这里传递的参数,到h5那边不执行那边的方法
-(void)loginCallBack
{
NSDictionary *dic;
user = [IBKeychain loadValueForKey:kUserKey];
if (user) {
dic= @{
@"id":[user objectForKey:@"userId"],
@"token":[user objectForKey:@"access_token"],
@"appTag":@"IOS"
};
}else{
dic= @{
// @"id":@"",
@"token":@"",
@"appTag":@"IOS"
};
}
NSData *jsonData = [NSJSONSerialization
dataWithJSONObject:dic options:0
error:nil];
NSString *result = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
NSString *jsStr = [NSString stringWithFormat:@"appLoginCallBack('%@');",result];
[self.webView stringByEvaluatingJavaScriptFromString:jsStr];
// return;
}
然后这样就可以调用方法了
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
[self hideLoadingView];
[self loginCallBack];
}