请帮助,我在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
答案 0 :(得分: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
答案 1 :(得分:0)
损坏的PDF文件导致比例适合剪掉边缘。删除并添加回项目为我工作。