问题描述
我做了一个使用UIWebView中显示,使用基本身份验证的网站的应用程序。它停止显示自iOS3.2的内容(在iPhone和iPad)。
I made an application that uses UIWebView to display a site that uses basic authentication. It stopped displaying the content since iOS3.2 (on both iPhone and iPad).
我来验证用户的做法是:
My approach for authenticating users are:
- 创建一个NSURLConnection的
- 实施didReceiveAuthenticationChallenge提供凭证
- 实施didReceiveResponse接收响应,并在一个UIWebView加载的要求,即[web视图的loadRequest:]
自从iOS3.2,认证被打破; UIWebView中似乎并没有要检查的共享凭据存储了。
Ever since iOS3.2, the authentication was broken; UIWebView doesn't seem to check against the shared credential storage any more.
有关iOS4的iPhone上,我设法解决此问题,愣神,包括URL登录informatino(即的)传递给web视图初始加载请求
For iOS4 on iPhone, I managed to work around this issue by, stupidly, including the login informatino in the URL (i.e. https://username:[email protected]) to the initial load request passed to the webView.
有关iOS3.2 iPad上,那是不够的。初始请求被认证没事,但后续调用仍然没有身份验证。
For iOS3.2 on iPad, that isn't enough. The initial request is authenticated all right, but the subsequent calls still aren't authenticated.
有什么建议?
推荐答案
使用 setDefaultCredential:forProtectionSpace
:在共享 NSURLCredentialStorage
web视图仍然使用默认的凭据,当您使用它不能正常工作 setCredential:forProtectionSpace
这篇关于UIWebView中不会对iOS3.2 / iOS4的持续认证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!