iOS 5 中的新错误:WebKit 丢弃了未捕获的异常

发布于 2024-12-10 14:53:12 字数 942 浏览 7 评论 0原文

我正在尝试使用 Facebook OAuth 授权 URL 加载 UIWebView ,并且使用以下代码。当我的 UIWebView 加载 Facebook 登录页面时,我输入我的凭据,然后按“登录”按钮。当我点击按钮时,我收到以下错误:

WebKit 在 webView 中丢弃了未捕获的异常:decidePolicyForNavigationAction:request:frame:decisionListener:delegate:应用程序试图以模态方式呈现活动控制器。

相同的代码在 iOS 4.3 及之前的版本中运行良好,但在 iOS 5.0 中不起作用。我不明白这个问题,有人可以帮助我吗?

NSString *redirectUrlString = @"http://www.facebook.com/connect/login_success.html";
NSString *authFormatString = @"https://graph.facebook.com/oauth/authorize?client_id=%@&redirect_uri=%@&scope=%@&type=user_agent&display=touch";

NSString *urlString = [NSString stringWithFormat:authFormatString, _apiKey, redirectUrlString, _requestedPermissions];
NSURL *url = [NSURL URLWithString:urlString];

NSLog(@"NSURL: %@", urlString);

NSURLRequest *request = [NSURLRequest requestWithURL:url];
[_webView loadRequest:request];

I am trying to load a UIWebView with the Facebook OAuth authorization URL and I am using the following code. When my UIWebView loads with Facebook login page, I enter my credentials, then press the "Log in" button. When I hit the button I am getting the following error:

WebKit discarded an uncaught exception in the webView:decidePolicyForNavigationAction:request:frame:decisionListener:delegate: Application tried to present modally an active controller .

This same code works fine with iOS 4.3 and previous versions, but it doesn't work in iOS 5.0. I don't understand the problem, can anyone please help me?

NSString *redirectUrlString = @"http://www.facebook.com/connect/login_success.html";
NSString *authFormatString = @"https://graph.facebook.com/oauth/authorize?client_id=%@&redirect_uri=%@&scope=%@&type=user_agent&display=touch";

NSString *urlString = [NSString stringWithFormat:authFormatString, _apiKey, redirectUrlString, _requestedPermissions];
NSURL *url = [NSURL URLWithString:urlString];

NSLog(@"NSURL: %@", urlString);

NSURLRequest *request = [NSURLRequest requestWithURL:url];
[_webView loadRequest:request];

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

韬韬不绝 2024-12-17 14:53:12

您使用的是 Ray Wenderlich 代码吗? (FBFunLoginDialog)..我发现这可以解决它:

-(void)checkLoginRequired:(NSString *)urlString {
    NSLog(@"Url: %@",urlString);
    if ([urlString rangeOfString:@"login.php"].location != NSNotFound && [urlString rangeOfString:@"refid"].location == NSNotFound) {
            [_delegate displayRequired];
    } else if ([urlString rangeOfString:@"user_denied"].location != NSNotFound) {
         [_delegate closeTapped];
    }
}

Are you using the Ray Wenderlich code? (FBFunLoginDialog).. I found that this fixes it:

-(void)checkLoginRequired:(NSString *)urlString {
    NSLog(@"Url: %@",urlString);
    if ([urlString rangeOfString:@"login.php"].location != NSNotFound && [urlString rangeOfString:@"refid"].location == NSNotFound) {
            [_delegate displayRequired];
    } else if ([urlString rangeOfString:@"user_denied"].location != NSNotFound) {
         [_delegate closeTapped];
    }
}
赠我空喜 2024-12-17 14:53:12

我有同样的问题。我尝试在关闭后立即呈现视图控制器。

[self dismissModalViewControllerAnimated:YES];

当我尝试在没有动画的情况下做到这一点时,效果非常好。使用missViewControllerAnimated:完成:

I have the same problem. I try to present view controller just after dismissing.

[self dismissModalViewControllerAnimated:YES];

When I try to do it without animation it works perfectly. use dismissViewControllerAnimated:completion:

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文