UIWebView横向旋转不填充视图 [英] UIWebView landscape rotation does not fill view
问题描述
我的UIWebView存在问题。当视图加载时,它以任意方向加载,完美填充整个页面等。
I am having an issue with my UIWebView. When the view loads it loads in either orientation fine, fills the whole page perfectly etc.
但是如果我以纵向加载它然后旋转设备webview不填充一直到右手边,我不能为我的生活找出原因。
However say if I load it in portrait then rotate the device the webview does not fill all the way across to the right hand side and I cannot for the life of me figure out why.
这是我的观点做了加载方法
This is my view did load method
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib
if ([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationPortrait){
self.measurementsWebView.frame = CGRectMake(0, 0, 320, 367);
}else if ([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationLandscapeLeft || [[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationLandscapeRight){
self.measurementsWebView.frame = CGRectMake(0, 0, 480, 218);
}
NSString *path = [[NSBundle mainBundle] pathForResource:@"measurements" ofType:@"png"];
[measurementsWebView loadHTMLString:[NSString stringWithFormat:@"<html><body><img src=\"file://%@\"></body></html>",path] baseURL:nil];
measurementsWebView.scalesPageToFit = YES;
}
如果我查看界面构建器,我试图找到允许我设置扩展宽度的面板或者你所说的任何面板,但我能看到的就是这个。
If i look in interface builder I am trying to find the panel that allows me to set expanding width or what ever you call it, but all I can see is this.
任何帮助将不胜感激
推荐答案
您也可以将自动调整大小的蒙版设置为:
Instead of setting the frame manually, you could also set the auto-resizing masks as:
<$ c,而不是手动设置框架$ c> measurementsWebView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
这将调整webView的大小,以防你在屏幕上没有其他元素(我认为,你没有从调整大小 measurementsWebView
时使用的值中获取。或者,直接从笔尖,如下图所示:
which will resize the webView in case you have no other elements on the screen (which, I take it, you don't have, from the values you've used when resizing measurementsWebView
). Or, straight from the nib as shown in the following image:
可以通过单击底部名为自动调整大小的框中的红色条来设置掩码离开。
The masks can be set by clicking on the red bars in the box called Autosizing towards the bottom left.
这篇关于UIWebView横向旋转不填充视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!