ios - 在 Objective-C 的 UIWebView 上滚动时 PDF 文件挂起

标签 ios objective-c uiwebview

我是 iOS 新手,当我在 UIWebView 上滚动 PDF 文件时它挂起。我正在使用这样的代码

 String = [String stringByReplacingOccurrencesOfString:@" " withString:@"%20"];
    NSString *urlAddress = String;
    NSURL *url = [[NSURL alloc] initWithString:urlAddress];
    NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
    NSLog(@"Downloading Started");
    NSString *urlToDownload = String;
    NSURL  *url = [NSURL URLWithString:urlToDownload];
    NSData *urlData = [NSData dataWithContentsOfURL:url];
    if ( urlData )
    {
        NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
        NSString  *documentsDirectory = [paths objectAtIndex:0];
        NSString *Title=TranningTitle;
        Title = [Title stringByReplacingOccurrencesOfString:@" " withString:@"%20"];
        NSString *format=@".pdf";
        NSString *finalString=[NSString stringWithFormat:@"%@%@",Title,format];
        NSString  *filePath = [NSString stringWithFormat:@"%@/%@", documentsDirectory,finalString];
        NSLog(@"File Path =%@",filePath);
        //saving is done on main thread
        dispatch_async(dispatch_get_main_queue(), ^{
            [urlData writeToFile:filePath atomically:YES];
            NSLog(@"File Saved !");
            [Showwebview loadRequest:requestObj];
        });
    }
});

它主要卡在 iPad 上。

最佳答案

尝试使用 Quicklook 框架。 Click here for sample code

关于ios - 在 Objective-C 的 UIWebView 上滚动时 PDF 文件挂起,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47173646/

相关文章:

iphone - 在 Iphone SDK 中更改网页 View 的字体大小

ios - 如何更改标签栏上的非事件图标/文本颜色?

objective-c - 取消选择 NSTextField 中的文本

ios - NSDictionary到多维数组iOS?

ios - 将 imageView 传递给下一个事件,是否需要 socket

iphone - 如何在 Tab Bar + NavigationControllers 应用程序中启用横向?

ios - 尝试在 iPhone 上以模态方式呈现 UIImagePickerController 时崩溃

ios - 关闭 UIWebView 后保持 session

iOS UIWebview 使用 HTML 表单从 app 目录上传

html - 如何允许缩放 UIWebView(什么都试过了)