gpt4 book ai didi

ios - 在 webview 上自动调整掩码没有任何区别

转载 作者:行者123 更新时间:2023-11-28 20:20:37 25 4
gpt4 key购买 nike

如何向 Web View 添加自动调整大小掩码。

我试过了

[self.webView setAutoresizingMask:UIViewAutoresizingFlexibleBottomMargin];
[self.webView reload];

Web View 不会根据模态对话框的大小而改变大小。如果方向发生变化,那么我会更改模态对话框的大小,以便键盘不会越过文本框。虽然 webview 大小没有改变。

我希望当模态对话框的高度较小时,webview 保持在顶部并降低高度。

我也试过手动调整它的大小,但 webview 不想改变大小。这是我试图手动更改它

self.webView.frame = CGRectMake(self.webView.frame.origin.x, self.webView.frame.origin.y, self.webView.frame.size.width, 0);
[self.webView reload];

最佳答案

[self.webView setAutoresizingMask:UIViewAutoresizingFlexibleBottomMargin];

表示 View 可以改变它的高度以保持它的底部和它的父 View Controller 底部之间的相同距离

self.webView.frame = CGRectMake(self.webView.frame.origin.x, self.webView.frame.origin.y, self.webView.frame.size.width, 0);

表示您想更改 View 的尺寸,使其保持相同的原点 x、y、相同的宽度,但高度为 0...

你可能想做的是 CGRect parentFrame = self.webView.superview.frame self.webview.frame = CGRectMake(0, 0, parentFrame.size.width, parentFrame.size.height);

 [self.webView setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)];

然后你的 webview 应该总是完全填充它的父 View

注意 [self.webview 重新加载];不重绘 webview 但重新加载 html 页面

关于ios - 在 webview 上自动调整掩码没有任何区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16193425/

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