0

请帮忙,我在 UIWebView 中有一个 PDF,它向右移动,切断了边框和一些内容。将设备置于横向,然后打开包含 webview/pdf 的页面会导致这种情况发生。这发生在设备和模拟器中。这是代码。

#import "waterTwoViewController.h"

@interface waterTwoViewController ()

@end

@implementation waterTwoViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
    // Custom initialization
}
return self;
} 

- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.


double screenWidth = [UIScreen mainScreen].bounds.size.width;
double screenHeight = [UIScreen mainScreen].bounds.size.height;

UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, screenWidth,   
screenHeight)];

webView.scalesPageToFit=YES;
webView.contentMode = UIViewContentModeScaleToFill;
webView.multipleTouchEnabled = YES;
webView.autoresizingMask = UIViewAutoresizingFlexibleWidth | 
UIViewAutoresizingFlexibleHeight;
[self.view addSubview:webView];


NSString *path = [[NSBundle mainBundle] pathForResource:@"WaterLineSizingValues"   
ofType:@"pdf"];
NSURL *targetURL = [NSURL fileURLWithPath:path];
NSURLRequest *request = [NSURLRequest requestWithURL:targetURL];
[webView loadRequest:request];




}

- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

@end
4

2 回答 2

2

为什么要将 UIWebView 两次添加到视图中?

[self.view addSubview:webView];


[self.view addSubview:webView];

好的试试这个

UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width,   
self.view.bounds.size.height)];
webview.backgroundColor = [UIColor redColor]; //check whether webview is the epicenter of the problem
webView.scalesPageToFit=YES;
webView.contentMode = UIViewContentModeScaleToFill;
webView.multipleTouchEnabled = YES;
webView.autoresizingMask = UIViewAutoresizingFlexibleWidth | 
UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleLeftMargin; //so that the webview is fixed to the top left corner an expands on all other sides
于 2013-09-03T09:07:10.440 回答
0

损坏的 PDF 文件导致比例尺适合剪裁边缘。删除并添加回对我有用的项目。

于 2013-09-09T18:24:31.903 回答