gpt4 book ai didi

iphone - shouldAutorotateToInterfaceOrientation & UINavigationController

转载 作者:搜寻专家 更新时间:2023-10-30 20:27:31 25 4
gpt4 key购买 nike

我正在尝试在我的应用程序中实现自动旋转,该应用程序基本上是 UINavigationController,其中有很多 UIViewControllers 被推送到它上面。

我已经将它复制粘贴到我的第一个 UIViewController 中(它被推送到 UINavigationController 中):

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return YES;}

一切正常...但是,如果我将该代码粘贴到第二个 UIViewController 中(第一个在单击某些按钮后推到顶部)- 自动旋转将不起作用。 shouldAutorotateToInterfaceOrientation 在 UIViewController 首次初始化时被调用,但在它可见并且我旋转设备后 - 没有任何反应。

因此结果是:第一个 View 旋转得很好 - 纵向/横向......但是在我单击按钮并进入第二个 View 后,我仍然停留在那个纵向或横向,无论是事件的。

我尝试子类化 UINavigationController 并在那里设置 shouldAutorotateToInterfaceOrientation,但这也不起作用。

我做错了什么?

最佳答案

API 中存在一个错误,导致它无法用于第二个 View 。我最初使用 setOrientation 解决了它,但这是一个私有(private) API,因此不是一个合理的解决方案。在尝试找出替代方案时,我还没有发布任何新版本的应用程序(而且我不认为让客户升级到 OS 4.0 是一种解决方案)。我想我需要手动跟踪方向并手动旋转我的 View 以抵消错误旋转的影响。

关于iphone - shouldAutorotateToInterfaceOrientation & UINavigationController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2783374/

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