UIWebView didFinishLoad没有触发

时间:2012-08-09 19:53:36

标签: ios uiwebview

我尝试登录到gmail表单,然后检查链接以查看他是否已登录。这是代码。

- (IBAction)loginToForm:(id)sender {
    NSString *zname= username.text;
    NSString *passwordEnter= password.text;
    [webView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"document.getElementsByName('Email')[0].value = '%@';",zname]];
    [webView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"document.getElementsByName('Passwd')[0].value = '%@';",passwordEnter]];
    [webView stringByEvaluatingJavaScriptFromString:@"document.getElementsByName('signIn')[0].click();"];
}

- (void)webViewDidFinishLoad:(UIWebView *)webView{
    NSString *returnData = [webView stringByEvaluatingJavaScriptFromString:@"window.location"];
    NSLog(@"%@",returnData);
    if([returnData rangeOfString:@"ServiceLogin"].location != NSNotFound){
        success=YES;
        NSLog(@"YES"); 
    }else{
        NSLog(@"NO");
    }
}

但是,webViewDidFinishLoad不会触发。任何帮助?谢谢伙计们!

0 个答案:

没有答案