大佬教程收集整理的这篇文章主要介绍了iphone – 如何使用iOS中的图像缓存整个网页,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
谢谢!
在我上面喜欢的页面上,有一些很好的例子,如何使用它,但我会包括其中一个在这里完整性:
- (IBACtion)loadURL:(NSURL *)url { // Assume request is a property of our controller // First,we'll cancel any in-progress page load [[self request] setDelegate:nil]; [[self request] cancel]; [self setrequest:[ASIWebPagerequest requestWithURL:url]]; [[self request] setDelegate:self]; [[self request] setDidFailSELEctor:@SELEctor(webPageFetchFailed:)]; [[self request] setDidFinishSELEctor:@SELEctor(webPageFetchSucceeded:)]; // Tell the request to embed external resources directly in the page [[self request] setUrlreplacementMode:ASIreplaceExternalresourcesWithData]; // it is strongly recommended you use a download cache with ASIWebPagerequest // When using a cache,external resources are automatically stored in the cache // and can be pulled from the cache on subsequent page loads [[self request] setDownloadCache:[ASIDownloadCache sharedCache]]; // Ask the download cache for a place to store the cached data // This is the most efficient way for an ASIWebPagerequest to store a web page [[self request] setDownloadDesTinationPath: [[ASIDownloadCache sharedCache] pathToStoreCachedResponseDataForrequest:[self request]]]; [[self request] startAsynchronous]; } - (void)webPageFetchFailed:(ASIhttprequest *)therequest { // ObvIoUsly you should handle the error properly... NSLog(@"%@",[therequest error]); } - (void)webPageFetchSucceeded:(ASIhttprequest *)therequest { NSString *response = [NSString StringWithContentsOfFile: [therequest downloadDesTinationPath] encoding:[therequest responseEncoding] error:nil]; // Note we're setTing the baseURL to the url of the page we downloaded. This is important! [webView loadHTMLString:response baseURL:[request url]]; }
以上是大佬教程为你收集整理的iphone – 如何使用iOS中的图像缓存整个网页全部内容,希望文章能够帮你解决iphone – 如何使用iOS中的图像缓存整个网页所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。