问题描述
我在深圳图书馆进行测试,这里有名为“reader”无密码无线网 可以正常连接,但不能直接上网的。
每次打开网页时 如果没有进行“登录”操作 则会定位到一个2.2.2.2/login.html页 具体如下:
比如我在地址栏中输入: http://livepage.apple.com 第一次则这样定位 https://2.2.2.2/login.html?redirect=livepage.apple.com/
同时浏览器弹出一个身份验证的对话框 大致意思是问你”不能验证2.2.2.2的身份,是否继续“  对话框上有“显示证书” “取消” “继续”按钮
点继续后加载“https://2.2.2.2/fs/customwebauth/login.html?switch_url=https://2.2.2.2/login.html&ap_mac=00:1f:ca:cc:97:10&wlan=reader&redirect=livepage.apple.com/” 这个地址,网页是一个“登录”页 输入“证号”与“密码” 验证成功后 就可以正常
上网了 
我现在火狐、ie safari 都能正确弹出那个问是否继续的证书显示框,但我用UIWebView  上网时 网页一直在加载中 UIWebView 要怎么配置或操作才能跟正常的浏览器一样程现那个“登录”验证过程呀?

解决方案 »

  1.   

    - (void)webView:(id)fp8 resource:(id)fp12 didReceiveAuthenticationChallenge:(id)fp16 fromDataSource:(id)fp20;
    - (void)webView:(UIWebView *)webView
                                 resource:(NSObject *)resource
        didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
                           fromDataSource:(WebDataSource *)dataSource;
    - (void)webView:(id)webView resource:(id)resource didReceiveAuthenticationChallenge:(id)challenge fromDataSource:(id)dataSource {
        NSURLCredential *credential = [NSURLCredential credentialWithUser:@"user" password:@"password" persistence:NSURLCredentialPersistenceForSession];
        [[challenge sender] useCredential:credential forAuthenticationChallenge:challenge];
    }
      

  2.   

    + (void) addAuthToWebRequest:(NSMutableURLRequest*)requestObj email:(NSString*)email password:(NSString*)password{
    NSString *authString = [[[NSString stringWithFormat:@"%@:%@", email, password] dataUsingEncoding:NSUTF8StringEncoding] base64Encoding];authString = [NSString stringWithFormat: @"Basic %@", authString];[requestObj setValue:authString forHTTPHeaderField:@"Authorization"];
    }
    NSURL *url = [NSURL URLWithString:urlAddress];
    NSMutableURLRequest *requestObj = [NSMutableURLRequest requestWithURL:url];[Utility addAuthToWebRequest:requestObj email:[Account getCurrentAccount].email password:[Account getCurrentAccount].password];
      

  3.   

    这是哪个版本的api呀。。3.1.2支不支持呀?
      

  4.   

    #import <Foundation/Foundation.h>
    #import <UIKit/UIView.h>
    #import <UIKit/UIKitDefines.h>
    #import <UIKit/UIDataDetectors.h>enum {
        UIWebViewNavigationTypeLinkClicked,
        UIWebViewNavigationTypeFormSubmitted,
        UIWebViewNavigationTypeBackForward,
        UIWebViewNavigationTypeReload,
        UIWebViewNavigationTypeFormResubmitted,
        UIWebViewNavigationTypeOther
    };
    typedef NSUInteger UIWebViewNavigationType;@class UIWebViewInternal;
    @protocol UIWebViewDelegate;UIKIT_EXTERN_CLASS @interface UIWebView : UIView <NSCoding> { 
     @private
        UIWebViewInternal *_internal;
    }@property(nonatomic,assign) id<UIWebViewDelegate> delegate;- (void)loadRequest:(NSURLRequest *)request;
    - (void)loadHTMLString:(NSString *)string baseURL:(NSURL *)baseURL;
    - (void)loadData:(NSData *)data MIMEType:(NSString *)MIMEType textEncodingName:(NSString *)textEncodingName baseURL:(NSURL *)baseURL;@property(nonatomic,readonly,retain) NSURLRequest *request;- (void)reload;
    - (void)stopLoading;- (void)goBack;
    - (void)goForward;@property(nonatomic,readonly,getter=canGoBack) BOOL canGoBack;
    @property(nonatomic,readonly,getter=canGoForward) BOOL canGoForward;
    @property(nonatomic,readonly,getter=isLoading) BOOL loading;- (NSString *)stringByEvaluatingJavaScriptFromString:(NSString *)script;@property(nonatomic) BOOL scalesPageToFit;@property(nonatomic) BOOL detectsPhoneNumbers __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_NA, __MAC_NA, __IPHONE_2_0, __IPHONE_3_0);
    @property(nonatomic) UIDataDetectorTypes dataDetectorTypes __OSX_AVAILABLE_STARTING(__MAC_NA, __IPHONE_3_0);@end@protocol UIWebViewDelegate <NSObject>@optional
    - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType;
    - (void)webViewDidStartLoad:(UIWebView *)webView;
    - (void)webViewDidFinishLoad:(UIWebView *)webView;
    - (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error;@end
    这个是我在3.1.2sdk中找到的api