在 iPhone 的 UIWebView 中添加大文件时出现滚动问题

发布于 2025-01-06 00:41:27 字数 1407 浏览 0 评论 0原文

我遇到了有关 webView 和 Pdf 的问题..

当我加载一个 10 mb 大小的 pdf 文件时..

该文件需要很长时间才能加载,而且我的 Pdf 也不能很好地滚动...

任何人都可以告诉我什么可以问题是什么?

这是代码...

  if ([resource.resource_type isEqualToString:@"pdf"] ) {
    tempStr = [NSString stringWithFormat:@"%@.pdf",resource.resource_link];
    type = [NSString stringWithFormat:@"pdf"];

}
else {
    tempStr = [NSString stringWithFormat:@"%@.jpg",resource.resource_link];
    type = [NSString stringWithFormat:@"jpg"];

}


      NSArray *myArray = [tempStr componentsSeparatedByString:@"."];

        NSString *path = [[NSBundle mainBundle] pathForResource:[myArray objectAtIndex:0] ofType:[myArray objectAtIndex:1]];

        NSLog(@"array elemt :%@", [myArray objectAtIndex:0]);
        NSLog(@"array elemt 1 :%@", [myArray objectAtIndex:1]);

        NSLog(@"path is :%@",path);

        if (isFirstTime) {
            NSURL *targetURL = [NSURL fileURLWithPath:path];
            NSURLRequest *request = [NSURLRequest requestWithURL:targetURL];
            [docWebView loadRequest:request];
            isFirstTime = NO;
        }
        if(isLandscape == NO){
            docWebView.frame = CGRectMake(0.0, 44.0, 768.0, 960.0);
        }
        else {
            docWebView.frame = CGRectMake(0.0, 44.0, 1024.0, 700.0);
        }
        [self.view addSubview:docWebView];
        [self.view bringSubviewToFront:activity];

I am having a problem about webView and Pdf ..

When I load a pdf file that is having 10 mb size ..

the file takes a lot time to load and my Pdf also dosnt scroll well ...

can anyone tell me what can be the issue?

here is the code ...

  if ([resource.resource_type isEqualToString:@"pdf"] ) {
    tempStr = [NSString stringWithFormat:@"%@.pdf",resource.resource_link];
    type = [NSString stringWithFormat:@"pdf"];

}
else {
    tempStr = [NSString stringWithFormat:@"%@.jpg",resource.resource_link];
    type = [NSString stringWithFormat:@"jpg"];

}


      NSArray *myArray = [tempStr componentsSeparatedByString:@"."];

        NSString *path = [[NSBundle mainBundle] pathForResource:[myArray objectAtIndex:0] ofType:[myArray objectAtIndex:1]];

        NSLog(@"array elemt :%@", [myArray objectAtIndex:0]);
        NSLog(@"array elemt 1 :%@", [myArray objectAtIndex:1]);

        NSLog(@"path is :%@",path);

        if (isFirstTime) {
            NSURL *targetURL = [NSURL fileURLWithPath:path];
            NSURLRequest *request = [NSURLRequest requestWithURL:targetURL];
            [docWebView loadRequest:request];
            isFirstTime = NO;
        }
        if(isLandscape == NO){
            docWebView.frame = CGRectMake(0.0, 44.0, 768.0, 960.0);
        }
        else {
            docWebView.frame = CGRectMake(0.0, 44.0, 1024.0, 700.0);
        }
        [self.view addSubview:docWebView];
        [self.view bringSubviewToFront:activity];

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

哎呦我呸! 2025-01-13 00:41:27

10 Mb 是一个大文件,特别是如果它包含图像...尝试用 iBooks 打开它,看看需要多少时间..问题可能不在于你的代码,我认为它在于文件大小。

10 Mb is a large file especially if its contains images ... try to open it with iBooks and see how much time it will take .. the problem may not be with your code, i think its in the file size.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文