即使在实现 shouldAutorotateToInterfaceOrientation 后视图也不会调整大小

发布于 2025-01-04 01:28:48 字数 147 浏览 2 评论 0原文

对于我的代码, shouldAutorotateToInterfaceOrientation 被调用,我在那里返回 YES,但是当我旋转设备时,控制器的视图会更改其大小,但主视图内的 UIImageView 不会更改其大小。我希望它像主视图一样调整大小。

提前致谢

for my code,
shouldAutorotateToInterfaceOrientation is getting called and i am returning YES there but still when I rotate the device, controller's view change its size but a UIImageView inside the main view does not change its size. I want it to be resized just like the main view.

thanks in advance

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

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

发布评论

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

评论(1

别再吹冷风 2025-01-11 01:28:48

设置 autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth 根据您的需要。

在代码中

imageview = [[UIImageView alloc] initWithFrame:CGRectMake(40,40,120,100)];
imageview.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleBottomMargin;

如果您已在 xib 中创建,则在 IB 中设置
如下图所示
在此处输入图像描述

set the autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth according to your need.

In code

imageview = [[UIImageView alloc] initWithFrame:CGRectMake(40,40,120,100)];
imageview.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleBottomMargin;

If you have created in xib then in IB set
this as shown in the below image
enter image description here

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