【问题标题】:UIWebview won't load dynamically loaded resources (via jQuery mobile) over basic authenticationUIWebview 不会通过基本身份验证加载动态加载的资源(通过 jQuery 移动)
【发布时间】:2012-09-07 09:08:09
【问题描述】:

有点混乱,不确定解决方案(或问题)的来源。

我正在使用 UIWebviews 和 Jquery Mobile 创建一个 iPad 应用程序。我必须通过基本身份验证访问我的网络资源。我已将 UIWebview 设置为通过 HTTP 请求正确发送我的登录凭据,并且所有资源和页面所需的资源(CSS、Javascript 等)都正确加载....

...除了那些通过 Javascript 动态加载的资源。

我使用 Modernizr 加载 CSS 文件,使用 JQuery 加载 .JSON 文件,当通过 webView 访问我的页面时,这些文件都没有加载。 (当我直接通过 Safari 访问该页面时,它工作正常)。

我猜这是一个 Xcode / iOS 问题,但我不知道从哪里开始。

任何帮助/指针都会很棒!

【问题讨论】:

    标签: javascript jquery ios xcode basic-authentication


    【解决方案1】:

    可以在这里找到答案:How to do authentication in UIWebView properly?

    报价解决方案:

        NSString* login = @"MYDOMAIN\\myname";
        NSURLCredential *credential = [NSURLCredential credentialWithUser:login
                                                                 password:@"mypassword"
                                                              persistence:NSURLCredentialPersistenceForSession];
    
        NSURLProtectionSpace *protectionSpace = [[NSURLProtectionSpace alloc]
                                                 initWithHost:@"myhost"
                                                 port:80
                                                 protocol:@"http"
                                                 realm:@"myhost" // check your web site settigns or log messages of didReceiveAuthenticationChallenge
                                                 authenticationMethod:NSURLAuthenticationMethodDefault];
    
    
        [[NSURLCredentialStorage sharedCredentialStorage] setDefaultCredential:credential forProtectionSpace:protectionSpace];
        [protectionSpace release];    
    

    【讨论】:

      猜你喜欢
      • 2019-10-30
      • 2018-06-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-04
      • 2015-09-04
      相关资源
      最近更新 更多