UIWebview赢得't通过基本身份验证加载动态加载的资源(通过jQuery mobile)

UIWebview won't load dynamically loaded resources (via jQuery mobile) over basic authentication

本文关键字:加载 资源 动态 通过 mobile jQuery 身份验证 赢得 UIWebview      更新时间:2023-09-26

有点令人困惑,不确定解决方案(或问题)的来源。

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

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

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

因此,我猜测这是一个Xcode/iOS问题,但我不确定从哪里开始。

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

答案可以在这里找到:如何正确地在UIWebView中进行身份验证?

报价解决方案:

    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];