Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/103.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UIWebView向右移动Xcode 4.6.3_Ios_Xcode_Pdf_Uiwebview - Fatal编程技术网

Ios UIWebView向右移动Xcode 4.6.3

Ios UIWebView向右移动Xcode 4.6.3,ios,xcode,pdf,uiwebview,Ios,Xcode,Pdf,Uiwebview,请帮忙,我在UIWebView中得到了一个PDF,它移到了右边,切断了边框和一些内容。将设备放入横向视图,然后打开包含webview/pdf的页面,会导致这种情况发生。这发生在设备和模拟器上。这是密码 #import "waterTwoViewController.h" @interface waterTwoViewController () @end @implementation waterTwoViewController - (id)initWithNibName:(NSStri

请帮忙,我在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

为什么要在视图中添加两次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

损坏的PDF文件导致缩放适合剪裁边缘。删除并添加回为我工作的项目

仅供参考,不要为了修正错误而不必要地删除一个问题并发布另一个问题。你可以编辑你的问题来修正打字错误,并根据需要添加额外的信息。明白了。我不想让事情变得混乱。我不知道为什么我会把它放在那里,很好。我去掉了它,我仍然得到同样的效果。任何人都能重现这种效果。我发现将设备放入横向视图,然后打开页面会导致这种情况。我将编辑这个问题。它似乎解决了问题,但现在它在返回到“肖像”时做了相同的事情,但我现在能够滚动到剪裁区域,仍然不正确。看起来当切换方向时,视图被放大了。@好斗的是,你现在应该可以在屏幕上看到红色在两个方向上。是吗?是的,它给了我一个红色的背景。已删除第一行,因为已定义了。我仍然得到同样的效果。我开始认为UIWebView不是显示pdf的最佳方式。很明显我是新来的。显示存储在支持文件中的pdf的标准做法是什么?webview使加载pdf更容易相信我,我已经测试了其他方法,所有方法都是PIA.Correction@satheeshwaran PDF很好,但仍然没有解决方案。它刚刚开始工作。不知道为什么,所以我做了一些不同的事情,这样就不会有任何问题。以下代码对我来说效果更好:NSString*path=[[NSBundle mainBundle]pathForResource:@“FileName”of type:@“pdf”];NSURL*url=[NSURL fileURLWithPath:path];NSURLRequest*request=[nsurlRequestRequestWithURL:url]//下面的名称(Webview)必须与插座相同[_WebViewLoadRequest:request];[_webviewsetscalespagetofit:YES];