【问题标题】:New error in iOS 5: WebKit discarded an uncaught exceptioniOS 5 中的新错误:WebKit 丢弃了一个未捕获的异常
【发布时间】:2011-12-10 08:31:59
【问题描述】:

我正在尝试使用 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];

【问题讨论】:

    标签: objective-c ios cocoa-touch uiwebview uiwebviewdelegate


    【解决方案1】:

    您使用的是 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];
        }
    }
    

    【讨论】:

    • 非常感谢 Karl Goodhew!
    • 现在我收到此错误该怎么办请帮助安全警告:“请像对待密码一样对待上面的 URL,不要与任何人分享。我在网上搜索了很多,但没有任何效果有人说将 url 从 http 更改为 https,有人说在 facebook 帐户中禁用安全浏览,但这些都不起作用。任何帮助
    【解决方案2】:

    我也有同样的问题。我尝试在关闭后展示视图控制器。

    [self dismissModalViewControllerAnimated:YES];
    

    当我尝试在没有动画的情况下进行时,它可以完美运行。使用dismissViewControllerAnimated:completion:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-12-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多