How to deal with proxy setting in UIWebView?

后端 未结 1 487
深忆病人
深忆病人 2021-01-22 07:28

I am learning to create my own web browser for iPhone. I use UIWebView, and using this article, I can create it easily.

But the problem arises when I had to

1条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-22 08:07

    Well, this is the first time I answered my own question. It solved rather easily : use this library : ASIHTTPRequest. So I change my code from this :

    NSURL *url = [NSURL URLWithString:[addressBar text]];
    NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url];
    [webView loadRequest:urlRequest];
    [addressBar resignFirstResponder];
    

    Into this :

    NSString *urlAddress = @"http://www.google.com";
    NSURL *url = [[NSURL URLWithString: [urlAddress stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]] retain];
    ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
    
    [request setUsername:@""];
    [request setPassword:@""];
    
    [request startSynchronous];
    

    It will prompt for username & password if needed.

    Thanks

    0 讨论(0)
提交回复
热议问题