gpt4 book ai didi

iphone - 在 ios 中使用 ASIHTTPRequest 加载 Web View 需要更多时间

转载 作者:可可西里 更新时间:2023-11-01 06:11:51 25 4
gpt4 key购买 nike

在我基于浏览器的应用程序中,我需要为每个 url 设置一个代理,并在 ASIHTTPRequest 的帮助下完成此操作。

我面临的问题是 WebView 加载页面的时间加倍,可能是因为我在代码中加载了两次页面。

首先,我使用 ASIHTTPRequest 检查状态以确定 ASIHTTPRequest 是否允许加载该页面,如果允许,然后我在 web-view 上加载该 url。这就是我认为问题所在,因为我认为我正在加载 url 两次,这很耗时。

您能否就一次加载页面的其他方式提出建议,但支持使用代理设置检查经过身份验证的页面的方式,或者为我提供与此问题相关的指导链接?

NSString *response = [NSString stringWithContentsOfFile:
[theRequest downloadDestinationPath] encoding:[theRequest responseEncoding] error:nil];
int statusCode = [requestH responseStatusCode];
if (statusCode == 200) {
[webV loadRequest:[NSURLRequest requestWithURL:[requestH url]]];
}
else {
[webV loadHTMLString:response baseURL:[theRequest url]];
}

最佳答案

实现 NSURLConnection ( apple docu ) 的委托(delegate)方法,并在 connectionDidFinishLoading 中将 url 的内容保存到本地文件,然后使用 loadHTMLString 加载此本地文件。

关于iphone - 在 ios 中使用 ASIHTTPRequest 加载 Web View 需要更多时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10811228/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com