如果您使用MGTwitterEngine,請轉到SA_OAuthTwitterController.m。並改變這一點:
- (void) webViewDidFinishLoad: (UIWebView *) webView {
NSError *error;
NSString *path = [[NSBundle mainBundle] pathForResource: @"jQueryInject" ofType: @"txt"];
NSString *dataSource = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:&error];
if (dataSource == nil) {
//YFLog(@"An error occured while processing the jQueryInject file");
}
//DLog(@"%@", [_webView stringByEvaluatingJavaScriptFromString:@"document.getElementsByTagName('body')[0].innerHTML"]);
[_webView stringByEvaluatingJavaScriptFromString:dataSource]; //This line injects the jQuery to make it look better
//check for auth_pin element
NSString *authPin = [[_webView stringByEvaluatingJavaScriptFromString: @"document.getElementById('oauth_pin').innerHTML"] stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]];
authPin = [[_webView stringByEvaluatingJavaScriptFromString: @"document.getElementById('oauth_pin').getElementsByTagName('kbd')[0].getElementsByTagName('code')[0].innerHTML"] stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]];
if (authPin.length == 0)
authPin = [[_webView stringByEvaluatingJavaScriptFromString: @"document.getElementById('oauth_pin').getElementsByTagName('a')[0].innerHTML"] stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]];
//if the auth pin not found than check for the auth-pin elenent
if (authPin == nil || authPin.length == 0) {
authPin = [[_webView stringByEvaluatingJavaScriptFromString: @"document.getElementById('oauth-pin').innerHTML"] stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]];
if (authPin.length == 0) {
authPin = [[_webView stringByEvaluatingJavaScriptFromString: @"document.getElementById('oauth-pin').getElementsByTagName('a')[0].innerHTML"] stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]];
}
}
[_activityIndicator stopAnimating];
if (authPin.length) {
[self gotPin: authPin];
}
if ([_webView isLoading] || authPin.length) {
[_webView setHidden:YES];
} else {
[_webView setHidden:NO];
}
}
現在問題解決了,認證窗口改回舊的。誰能解釋這種行爲?如果應用程序發佈後會再次發生,這是非常煩人的。我有一個完全不同的彈出窗口來授權您的帳戶與Twitter的應用程序。一小時後,它變回正常狀態。 – Tjekkles 2011-04-29 08:26:20
你有沒有試過在Twitter支持周圍詢問,他們控制整個事情。 – bh88 2011-04-29 16:55:04