只有 MainWindow 视图的直接子视图才能获得 iOS 设置的方向?

发布于 2024-09-12 03:06:03 字数 197 浏览 4 评论 0原文

每当我的应用程序旋转时,只有我将其视图作为子视图添加到主窗口的 viewController 才会更新其 interfaceOrientation 属性,其余部分仍然不知道设备已旋转的事实。

我有责任将更改通知其他对象吗?如果是,那么有什么好的方法可以做到这一点?

我已经研究过设置子视图控制器的界面方向,但这是只读的。

提前致谢,

Whenever my app is rotated, only the viewController of which I've added his view as a subview to the mainwindow gets his interfaceOrientation property updated, the rest remains ignorant of the fact the device has been rotated.

Is it my responsibilty to notify other objects of the change, and if so, what's a nice way to do it?

I've looked into setting interfaceOrientation of my children-viewcontrollers but that's readonly.

Thanks in advance,

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

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

发布评论

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

评论(1

沫离伤花 2024-09-19 03:06:03

调用

willRotateToInterfaceOrientation

和/或

didRotateFromInterfaceOrientation

我发现您要显示的视图控制器的 对我有用。就我而言,我使用的是导航控制器,因此可以轻松跟踪接下来将向用户显示的内容。下面是我的项目中的一些代码。

- (void)navigationController:(UINavigationController *)navigationController 
         didShowViewController:(UIViewController *)viewController 
         animated:(BOOL)animated {
    [viewController willRotateToInterfaceOrientation:
        [self interfaceOrientation] duration:0];    
}

I found that calling

willRotateToInterfaceOrientation

and/or

didRotateFromInterfaceOrientation

of the view controller you are going to show worked for me. In my case I was using a Navigation Controller so it was easy to keep track of what was going to be shown to the user next. Below is some code from my project.

- (void)navigationController:(UINavigationController *)navigationController 
         didShowViewController:(UIViewController *)viewController 
         animated:(BOOL)animated {
    [viewController willRotateToInterfaceOrientation:
        [self interfaceOrientation] duration:0];    
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文