jjzjj

ios - shouldAutorotateToInterfaceOrientation : never called

coder 2024-01-15 原文

我在 Deployment Info 下将支持的界面方向设置为除纵向倒置外的所有界面方向。

我想覆盖 shouldAutorotateToInterfaceOrientation: 自定义行为。 (即根据条件支持横向)

由于限制(自定义 View 转换),我只有一个 View Controller

这是我的 appdelegate 中的代码:

self.viewController = [[MyController alloc]initWithNibName:nil bundle:nil];

self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;

在 myController.m 中,我覆盖了 shouldAutorotateToInterfaceOrientation:

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

应用程序自动旋转到所有方向,但纵向倒置并且永远不会调用回调。我已经尝试了 change return from shouldAutorotateToInterfaceOrientation: at runTime 的建议没有成功。为什么?

旁注,在运行时更改旋转支持的最佳方法是什么?

更新:

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration

被调用。我试着放在

[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait];

没有成功:(

最佳答案

正在使用 ios6

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation

在 ios6 上已弃用

关于ios - shouldAutorotateToInterfaceOrientation : never called,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12105085/

有关ios - shouldAutorotateToInterfaceOrientation : never called的更多相关文章

随机推荐