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];
}