在 iPhone 的 UIWebView 中添加大文件时出现滚动问题
我遇到了有关 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
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.