有点令人困惑,不确定解决方案(或问题)的来源.
我正在使用UIWebviews和Jquery Mobile创建一个iPad应用程序.我不得不通过基本身份验证访问我的Web资源.我已经设置了UIWebview以通过HTTP请求正确发送我的登录凭据,并且所有资源和页面所需的资源(CSS,Javascript等)都正确加载….@H_502_3@
…除了那些通过Javascript动态加载的资源.@H_502_3@
我使用Modernizr加载CSS文件和JQuery加载.JSON文件,当通过webView访问我的页面时,没有加载这些文件. (当我直接通过Safari访问页面时,它工作正常).@H_502_3@
我猜它是一个Xcode / iOS问题,但我不知道从哪里开始.@H_502_3@
任何帮助/指针都会很棒!@H_502_3@
解决方法
答案可以在这里找到:
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];