我在部署信息下将支持的界面方向设置为除了纵向颠倒之外。
我想覆盖 shouldAutorotateToInterfaceOrientation: 用于自定义行为。(即根据条件支持景观)
由于约束,我只有一个视图控制器(自定义视图转换)
这就是我的 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;
}
应用程序自动旋转到所有方向,但纵向倒置,并且永远不会调用回调。我在运行时尝试了从 shouldAutorotateToInterfaceOrientation: 更改返回时的建议,但没有成功。为什么?
附带说明一下,在运行时更改旋转支持的最佳方法是什么?
更新:
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
被调用。我试着放入
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait];
没有成功:(