我正在尝试使用设备的整个屏幕在 UIWebview 中显示 pdf。我有一个在 iPad 上运行的 xcode 应用程序。我有一个滚动视图来滚动 pdf 页面 UIWebview 是 uiscrollview 的子视图。PDF是从互联网上下载的,没有问题,目前,PDF在显示时仅在uiwebview上以纵向模式使用屏幕的最上半部分。我需要它来跨越 UIWebview 整个视图。
NSString *strPageURL = [dictPage valueForKey:@"link"];
strPageURL = [strPageURL stringByReplacingOccurrencesOfString:@"\n" withString:@""];
strPageURL = [strPageURL stringByReplacingOccurrencesOfString:@"\t" withString:@""];
strPageURL = [strPageURL stringByReplacingOccurrencesOfString:@" " withString:@""];
NSString* strFileName = [strPageURL lastPathComponent];
NSString *strDestFile = [NSHomeDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"Documents/%@",strFileName]];
CGRect rect = CGRectMake(xPos, 0, scrollView.frame.size.width, scrollView.frame.size.height);
UIWebView * webView = [[UIWebView alloc] initWithFrame:rect];
webView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
[webView setContentMode:UIViewContentModeScaleAspectFit];
[webView setScalesPageToFit:YES];
webView.backgroundColor = [UIColor whiteColor];
webView.tag=3000+i;
BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:strDestFile];
if(fileExists)
{
NSURL *url = [[NSURL alloc] initFileURLWithPath:strDestFile];
[webView loadRequest:[NSURLRequest requestWithURL:url]];
[webView setDelegate:self];
[scrollView addSubview:webView];
}