gpt4 book ai didi

iphone - iOS 初学者 : Screen orientation

转载 作者:行者123 更新时间:2023-11-29 04:46:47 25 4
gpt4 key购买 nike

我创建了一个基于 Window 的应用程序,并添加了 2 个 UIView 子类,一个是主窗口,另一个是内容窗口。

我需要我的应用程序处于横向模式。现在,这是我所做的:

  • 在项目信息中添加了“初始界面方向”键,并将其设置为“横向
  • 将“支持的设备方向”设置为“横向
  • 在我的两个 View .m 文件中,我在 shouldAutorotateToInterfaceOrientation 函数中返回了 YES

这样就可以工作了。然而,当我在 View 之间切换时,由于某种原因,我在横向模式下看到了丑陋的基于纵向的界面,并且界面在大约 2 秒后切换到横向。为什么会这样?

最佳答案

您应该在 shouldAutorotateToInterfaceOrientation 中返回此内容:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight);

}

这是应用程序询问 View 是否可以旋转到新界面方向的地方

关于iphone - iOS 初学者 : Screen orientation,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9512884/

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