只是一個快速的一個,我怎樣檢測,如果登錄失敗,這裏是我的代碼:檢測網站登錄失敗objective-c?
- (IBAction)btnTimetable:(id)sender {
NSString *user = _txtUsername.text;
NSString *pass = _txtPassword.text;
NSString *content = [NSString stringWithFormat:@"username=%@&password=%@", user, pass];
NSData *data =[content dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString *postlenght=[NSString stringWithFormat:@"%lu",(unsigned long)[data length]];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@"http://moodle.thomroth.ac.uk/login/index.php?mode=login"]];
[request setHTTPMethod:@"POST"];
[request setValue:postlenght forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Length"];
[request setHTTPBody:data];
//NSError *error=nil;
//NSURLResponse *response=nil;
//NSData *result=[NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
[_webView loadRequest:request];
[self performSelector:@selector(parseTimetable) withObject:nil afterDelay:3.0];
}
我甚至不知道從哪裏開始就這一個是有一個委託方法來檢測這樣的行動?
UIWebView在存儲憑證時可能會遇到問題,甚至可能不支持身份驗證(還)。如果可能,您可以下載數據並在之後爲WebView進行設置。 – CouchDeveloper