Je consomme des données html json dans mon application iOS. La réponse HTML a quelques blocs div avec les méthodes onClick. Quand j'appuie sur ces blocs, j'appelle du code javascript dans la vue web, mais j'ai aussi besoin de connaître ces événements dans mon code source. Par exemple lorsque je tape sur l'élément web et onClick est appelé, j'ai besoin d'appeler une méthode dans le code.comment appeler méthode dans le code ios à partir de la réponse html en utilisant uiwebview
- (void)patientResponse:(UIWebView *)webView modeDict:(NSDictionary *)modeDict
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
NSString *protocolPrefix = EVENT;
NSString *urlStr = [[request URL].absoluteString substringFromIndex:protocolPrefix.length];
urlStr = [urlStr stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSError *jsonError;
NSDictionary *callInfo = [NSJSONSerialization
JSONObjectWithData:[urlStr dataUsingEncoding:NSUTF8StringEncoding]
options:kNilOptions error:&jsonError];
if([[callInfo valueForKey:@"acton"] isEqualToString:Set_id])
[self patientResponse:webView modeDict:callInfo];
return NO;
}
- (void)patientResponse:(UIWebView *)webView modeDict:(NSDictionary *)modeDict
{
NSString *mode = [[modeDict valueForKey:@"params"] valueForKey:@"PatientName"];
self.patientName = mode;
NSLog(@"Patient name is:%@",self.patientName);
}
aidez-moi n'importe quel corps –