gpt4 book ai didi

iphone - UIWebView 横向旋转不填充 View

转载 作者:可可西里 更新时间:2023-11-01 04:27:42 24 4
gpt4 key购买 nike

我的 UIWebView 有问题。当 View 加载时,它会以任一方向加载,完美地填充整个页面等。

但是如果我以纵向加载它然后旋转设备,webview 不会一直填充到右侧,我无法弄清楚为什么。

这是我的 View 加载方法

- (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;

}

如果我查看界面生成器,我会尝试找到允许我设置扩展宽度或任何你称之为的面板,但我只能看到这个。

enter image description here

任何帮助将不胜感激

最佳答案

除了手动设置框架,您还可以将自动调整大小的蒙版设置为:

measurementsWebView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

这将在屏幕上没有其他元素的情况下调整 webView 的大小(根据调整 measurementsWebView 大小时使用的值,我认为你没有)。或者,直接从 Nib 开始,如下图所示:

auto-resize from nib

可以通过单击左下方名为 Autosizing 的框中的红色条来设置 mask 。

关于iphone - UIWebView 横向旋转不填充 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11387467/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com