为什么视图自动调整大小在第一次定向时不起作用?

发布于 2024-10-08 18:18:44 字数 535 浏览 0 评论 0原文

加载视图后,我将方向更改为横向。在那里,我看到一条蓝色条带,并且视图向下移动。当我转到其他选项卡并返回时,它工作正常。

谁能帮我解决这个问题吗?

我这样做是为了自动调整视图大小:

-viewDidLoad:
{
self.view.autoresizingMask =( UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleRightMargin);
 self.view.autoresizesSubviews;
[super viewDidLoad];
}
-shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {

 return YES;
}

这是屏幕截图:

alt text

After the view is loaded, I changed the orientation to Landscape. There, I see a blue strip and the view is moved down. When I go to other tabs and come back, it is working fine.

Can anyone help me with this?

I have done this to autosize the view:

-viewDidLoad:
{
self.view.autoresizingMask =( UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleRightMargin);
 self.view.autoresizesSubviews;
[super viewDidLoad];
}
-shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {

 return YES;
}

Here is a screenshot:

alt text

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

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

发布评论

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

评论(1

我爱人 2024-10-15 18:18:44

我相信自动调整大小是在 viewDidLoad 之前触发的,该行为不一定定义良好。看看是否可以在初始化阶段添加自动调整大小蒙版选项(如果您从笔尖加载视图,甚至可以在界面生成器中添加)。总的来说,这里需要更多的信息来提供帮助 - 但请记住,当视图处于“viewDidLoad”状态时,已经对视图完成了很多操作(毕竟,它已经加载并准备好使用)。

I believe autoresizing is triggered before viewDidLoad, the behaviour isn't necessarily well defined. See if you can add your autoresizing mask option at the init stage (or even in interface builder if you're loading the view from a nib). Overall, much more info is needed here to help - but keep in mind that a lot of the stuff has been done to the view by the time it is in "viewDidLoad" (after all, it DID already load and ready to use).

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