iOS 5 中的新错误:WebKit 丢弃了未捕获的异常
我正在尝试使用 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您使用的是 Ray Wenderlich 代码吗? (FBFunLoginDialog)..我发现这可以解决它:
Are you using the Ray Wenderlich code? (FBFunLoginDialog).. I found that this fixes it:
我有同样的问题。我尝试在关闭后立即呈现视图控制器。
当我尝试在没有动画的情况下做到这一点时,效果非常好。使用missViewControllerAnimated:完成:
I have the same problem. I try to present view controller just after dismissing.
When I try to do it without animation it works perfectly. use dismissViewControllerAnimated:completion: