<bdo id='9AQ1g'></bdo><ul id='9AQ1g'></ul>
      1. <i id='9AQ1g'><tr id='9AQ1g'><dt id='9AQ1g'><q id='9AQ1g'><span id='9AQ1g'><b id='9AQ1g'><form id='9AQ1g'><ins id='9AQ1g'></ins><ul id='9AQ1g'></ul><sub id='9AQ1g'></sub></form><legend id='9AQ1g'></legend><bdo id='9AQ1g'><pre id='9AQ1g'><center id='9AQ1g'></center></pre></bdo></b><th id='9AQ1g'></th></span></q></dt></tr></i><div id='9AQ1g'><tfoot id='9AQ1g'></tfoot><dl id='9AQ1g'><fieldset id='9AQ1g'></fieldset></dl></div>

        <tfoot id='9AQ1g'></tfoot>

        <small id='9AQ1g'></small><noframes id='9AQ1g'>

        <legend id='9AQ1g'><style id='9AQ1g'><dir id='9AQ1g'><q id='9AQ1g'></q></dir></style></legend>

        在 UIWebView 中检测下载

        Detecting Download in UIWebView(在 UIWebView 中检测下载)
        • <legend id='ewPEn'><style id='ewPEn'><dir id='ewPEn'><q id='ewPEn'></q></dir></style></legend>
          <i id='ewPEn'><tr id='ewPEn'><dt id='ewPEn'><q id='ewPEn'><span id='ewPEn'><b id='ewPEn'><form id='ewPEn'><ins id='ewPEn'></ins><ul id='ewPEn'></ul><sub id='ewPEn'></sub></form><legend id='ewPEn'></legend><bdo id='ewPEn'><pre id='ewPEn'><center id='ewPEn'></center></pre></bdo></b><th id='ewPEn'></th></span></q></dt></tr></i><div id='ewPEn'><tfoot id='ewPEn'></tfoot><dl id='ewPEn'><fieldset id='ewPEn'></fieldset></dl></div>
        • <small id='ewPEn'></small><noframes id='ewPEn'>

          • <bdo id='ewPEn'></bdo><ul id='ewPEn'></ul>

                  <tbody id='ewPEn'></tbody>
                <tfoot id='ewPEn'></tfoot>
                • 本文介绍了在 UIWebView 中检测下载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个以编程方式创建的 UIWebView,它用于浏览存储在我的服务器上的 iPhone 风格的网站.在这个网站上,有一些用户可以下载到我的应用程序中的文件链接.现在,我正在尝试通过以下方式检测到这一点:

                  I have a programatically crated UIWebView, and it is used to browse a iPhone-style site stored on my server. In this website, there are a few links to files users can download into my application. Right now, I'm trying to detect this with:

                  - (BOOL) webView:(UIWebView *) webView shouldStartLoadWithRequest:(NSURLRequest *) request navigationType:(UIWebViewNavigationType) navigationType
                  {
                      url = [request URL];
                      NSString *mimeType = [request valueForHTTPHeaderField:@"Content-Type"];
                      NSLog(@"Content-type: %@", mimeType);
                      if(mimeType == @"application/zip" || mimeType == @"application/x-zip" || mimeType == @"application/octet-stream")
                      {
                          NSLog(@"Downloading file!");
                          [NSThread detachNewThreadSelector:@selector(download:) toTarget:self withObject:@"/tmp/file.ipa"];
                          return NO;
                      }
                      return YES;
                  }
                  

                  但是,当调用此方法时,内容类型标头几乎总是(null),所以我永远无法下载文件.

                  However, when this method is called, the content-type header is almost always (null), so I never am able to download a file.

                  你会如何正确地做到这一点?

                  How would you do this correctly?

                  推荐答案

                  您正在尝试从尚未生成的 NSURLRequest 中检测 Content-Type.在使用 NSURLConnection 发出请求之前,您不会知道 Content-Type.在这种情况下,我可能只会查看 URL 路径的文件扩展名.

                  You're trying to detect a Content-Type from an NSURLRequest which has not yet been made. You won't know the Content-Type until after the request is made using NSURLConnection. In this case, I'd probably just look at the file extension of the URL path.

                  这篇关于在 UIWebView 中检测下载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Getting an NSArray of a single attribute from an NSArray(从 NSArray 获取单个属性的 NSArray)
                  ImageIO: lt;ERRORgt; JPEG Corrupt JPEG data: premature end of data segment iphone - how to catch this?(ImageIO:lt;错误gt;JPEG 损坏的 JPEG 数据:iphone 数据段过早结束 - 如何捕捉到这个?)
                  Xcode iOS organizer submit to app store yields quot;The archive is invalidquot; error(Xcode iOS 管理器提交到应用商店产生“存档无效;错误)
                  MFMessageComposeViewController alloc returns nil(MFMessageComposeViewController alloc 返回 nil)
                  How to add and get the values from .plist in iOS(如何在 iOS 中从 .plist 添加和获取值)
                  Mobile Device Management with iPhone(使用 iPhone 进行移动设备管理)

                  <tfoot id='i3pCh'></tfoot>
                      <bdo id='i3pCh'></bdo><ul id='i3pCh'></ul>

                      <small id='i3pCh'></small><noframes id='i3pCh'>

                      <i id='i3pCh'><tr id='i3pCh'><dt id='i3pCh'><q id='i3pCh'><span id='i3pCh'><b id='i3pCh'><form id='i3pCh'><ins id='i3pCh'></ins><ul id='i3pCh'></ul><sub id='i3pCh'></sub></form><legend id='i3pCh'></legend><bdo id='i3pCh'><pre id='i3pCh'><center id='i3pCh'></center></pre></bdo></b><th id='i3pCh'></th></span></q></dt></tr></i><div id='i3pCh'><tfoot id='i3pCh'></tfoot><dl id='i3pCh'><fieldset id='i3pCh'></fieldset></dl></div>
                        <tbody id='i3pCh'></tbody>
                            <legend id='i3pCh'><style id='i3pCh'><dir id='i3pCh'><q id='i3pCh'></q></dir></style></legend>