0

NSURL で認証を行うことができ、ユーザーはユーザー名とパスワードを割り当てることができます。ただし、別の問題が発生しました。これを開くとhttp://html5test.com/、ポップアップしてユーザー名とパスワードを尋ねます。認証が取れないはずなのに認証が取れてしまいました。やり方を知りたいです。

-(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
   if(!_auth)
    {
   connection_for_auto = [[NSURLConnection alloc] initWithRequest:request delegate:self];
          firsttimeonly=TRUE;
         [connection_for_auto start];
        NSLog(@"Request >>  %@ and !firsttimeonly",request);
        return NO;
    }
    self.lbl_error.hidden = YES; //hide error message label
    return YES;

}

- (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
{

    checkTochangeUIalert=TRUE;
    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Login"
                                                    message:nil
                                                   delegate:self
                                          cancelButtonTitle:@"Cancel"
                                          otherButtonTitles:@"OK",@"Auto", nil];

    alertView.transform=CGAffineTransformMakeScale(1.0, 0.75);
    alertView.alertViewStyle = UIAlertViewStyleLoginAndPasswordInput;
    [alertView show];
}
4

1 に答える 1

0

方法を見つけたと思います。使用している認証方法を確認する必要があります。

if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodHTTPBasic] || [challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodNTLM])
{
.............
}
于 2013-04-02T01:31:34.470 に答える