为什么子视图在 InterfaceRotation 之后会调整大小?

发布于 2024-10-03 22:20:31 字数 282 浏览 0 评论 0原文

我正在向主视图控制器的 UiView 添加一个子视图,该子视图的呈现方式与具有 Formsheet 样式的 UIModalViewController 类似。 (所以它不会填充整个屏幕)

不,如果设备旋转子视图以某种方式调整大小以填充整个主视图...... 即使我手动设置:

subViewCtrl.view.autoresizingMask = UIViewAutoresizingNone;

它仍然会自动调整大小。 为什么它不能像其他子视图那样简单地停留在中间?

I'm adding a subview to the UiView of my mainviewcontroller, that is presented in a similar way as a UIModalViewController with the Formsheet-style. (so it doesn't fill teh whole screen)

No if the device rotates the subview somehow gets resized to fill the whole mainview...
Even if I manually set:

subViewCtrl.view.autoresizingMask = UIViewAutoresizingNone;

it still autoresizes.
Why can't it simple stay in the middle as any other subview would?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

终止放荡 2024-10-10 22:20:31

好吧,我自己想出来了。

我不小心

[self.view.superview addSubview:rowCtrl.view];

这样做了,所以我也改变了它

[self.view addSubview:rowCtrl.view];

,它按预期工作了。无论如何,谢谢!
当然,还需要设置一下

rowCtrl.view.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleBottomMargin;

,否则界面旋转时无法正确居中。

Ok, I figured it out myself.

I accidentally did

[self.view.superview addSubview:rowCtrl.view];

so I changed this too

[self.view addSubview:rowCtrl.view];

and it worked as intended. Thanks anyway!
Of course, then one also has to set

rowCtrl.view.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleBottomMargin;

otherwise it doesn't get centered properly when the interface rotates.

温暖的光 2024-10-10 22:20:31

视图的大小是否正在调整,或者视图在屏幕尺寸发生变化时保持相同的大小?您可能需要 UIViewAutoresizingFlexibleWidth 和/或 UIViewResizingFlexibleHeight。如果您使用这些值,那么您的子视图将调整大小以与屏幕边缘保持恒定距离;您的视图将改变大小,但保持居中。

Is the view resizing, or is the view staying the same size while the dimensions of the screen change? You may want UIViewAutoresizingFlexibleWidth and/or UIViewResizingFlexibleHeight. If you use those values then your subview will resize to remain a constant distance from the edges of the screen; your view will change sizes, but remain centered.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文