【问题标题】:Changing root controller causes view to rotate to correct position更改根控制器会导致视图旋转到正确位置
【发布时间】:2013-01-13 01:59:39
【问题描述】:

首先我想说这个问题并没有解决我的问题:Orientation problem when I set a RootViewController

我的 ipad 应用程序只能在横向模式下工作。当我更改根控制器时,新的故事板会正确显示。但是,它以纵向模式出现,然后旋转到正确的方向。如何在更改根控制器之前指定方向或告诉故事板默认以横向显示?在动画之后看到视图的旋转非常难看。

另外,在项目属性中设置左右景观。

这是我更改根视图控制器时的代码。

UIStoryboard *editorStoryboard = [UIStoryboard storyboardWithName:@"EditorStoryboard" bundle:nil];
UISplitViewController *editorViewController = [editorStoryboard instantiateInitialViewController];

UINavigationController *navigationController = [editorViewController.viewControllers lastObject];
editorViewController.delegate = (id)navigationController.topViewController;


AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;

[UIView transitionWithView:appDelegate.window duration:0.5 options: UIViewAnimationOptionTransitionFlipFromLeft animations:^{
    appDelegate.window.rootViewController = editorViewController;
} completion:nil];

【问题讨论】:

  • 您是否检查了应用程序目标摘要中的Supported Interface Orientations 仅选择了Landscape LeftLandscape Right(根据您的需要)
  • 是的,已经检查过了,忘记添加了
  • 如果它们被选中,详细信息将保存在 Info.plist 中,因此应用程序最初将以纵向模式加载。所以只选择横向模式
  • 我的意思是检查左右横向。
  • 我找到了答案。这是工作正常。 [stackoverflow.com/questions/8053832/…[1]:stackoverflow.com/questions/8053832/…

标签: ios objective-c ipad user-interface


【解决方案1】:

你有没有尝试覆盖

preferredInterfaceOrientationForPresentation

对于新的根视图控制器?像这样的:

-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationLandscape
}

来自View Controller Programming Guide for iOS

编辑:好的,尝试摆脱动画怎么样?

【讨论】:

  • 是的,它仍然是纵向然后旋转到横向。
猜你喜欢
  • 2019-09-01
  • 1970-01-01
  • 1970-01-01
  • 2019-03-06
  • 1970-01-01
  • 1970-01-01
  • 2013-10-12
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多