If I load a PDF into a UIWebView:
if (!bundle)
bundle = [NSBundle mainBundle];
NSString *filePath = [bundle
pathForResource:fileName ofType:@"pdf"];
UIWebView *webView = [[[UIWebView alloc] initWithFrame:view.bounds] autorelease];
webView.scalesPageToFit = YES;
[view addSubview:webView];
NSURL *pdfURL = [NSURL fileURLWithPath:filePath];
NSURLRequest *request = [NSURLRequest requestWithURL:pdfURL];
[webView loadRequest:request];
the app acts just like Mobile Safari except when it has to do paging:
Mobile Safari pages without pause, showing the parts that it is rendering as checkerboard. UIWebView, in contrast, stops movement, and eventually jerks to the new position.
MobileSafari works nicely and UIWebView is unacceptable. What other options do I have for displaying a multi开发者_如何学运维page PDF? Or do I need to handle the multipage aspect by myself using CGPDFPageRef?
EDIT Just realized that the link refers to OS X programming, not iOS. Sorry.
Hello,
I tried out some similar code I ran into the same issue, so there is definitely some difference between the browser and the UIWebView
.
In researching the problem I can across this SO thread: "PDF in webview performance" I think the last post may help you out.
EDIT 2:
The solution I would use is to convert your PDF into an image, and load that in an imageview with scrolling. Initially it might take a moment to load, but the scrolling action will be smooth and will not lag.
精彩评论