我可以向UIWebView.But显示url如何下载文件并将文件从UIWebView保存到文件夹单击下载链接时。
答案 0 :(得分:3)
在您的网络视图委托中实施webView:shouldStartLoadWithRequest:navigationType:
。如果您收到对您感兴趣的文件的请求,请从该方法返回NO
并开始单独NSURLConnection
将文件下载到NSData
对象中,然后您可以保存该对象。
答案 1 :(得分:0)
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *) request navigationType:(UIWebViewNavigationType)navigationtype
{
// Will execute this block only when links are clicked
if( navigationtype == UIWebViewNavigationTypeLinkClicked )
{
...//create NSURLConnection object and save the downloaded bytes in NSData in
connectionDidFinishLoading:(NSURLConnection *)connection
}
}