0

最初に URL をロードする Webview があり、これは自動的にhttps://secure.authorize.net/gateway/transact.dllにリダイレクトされます。

しかし、デリゲート機能

ない

- (void)connection:(NSURLConnection *)connection willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge;

または

-(NSURLRequest *)connection:(NSURLConnection *)connection willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse;

呼び出します。だから私は空白のページだけを手に入れました。これで私を助けてください。

この関数を使用して初期 URL をロードしています

 myReq=[NSURLRequest requestWithURL:[NSURL URLWithString:myStr]];
    NSURLConnection *myConn=[NSURLConnection connectionWithRequest:myReq delegate:self];

    if(myConn){
        webdata = [[NSMutableData alloc] init];
    }

    -(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data{
    [webdata appendData:data];
}

-(void)connectionDidFinishLoading:(NSURLConnection *)connection{
    [[myWebView mainFrame] loadData:webdata MIMEType: @"text/html" textEncodingName: @"UTF-8" baseURL:nil];
}
4

1 に答える 1

1

サーバーがロードに失敗するたびにリクエストを再送信することで、これを修正しました。

- (void)webView:(WebView *)sender didFailProvisionalLoadWithError:(NSError *)error forFrame:(WebFrame *)frame{
NSLog(@"%@", [error description]);

NSURLConnection *myConnn=[NSURLConnection connectionWithRequest:[[[sender mainFrame] provisionalDataSource] request] delegate:self];

 if(myConnn)
    NSLog(@"I got it");

}

そして、デリゲート関数が呼び出されます。ここのサーバーは信頼できます。

- (void)connection:(NSURLConnection *)connection willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge{
NSURLProtectionSpace *space = [challenge protectionSpace];
[space serverTrust];
[challenge.sender useCredential:[NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust] forAuthenticationChallenge:challenge];

}

于 2012-11-02T09:59:52.447 に答える