我一直在尝试让多个方向与单个 View Controller 一起工作。目前它检查设备方向和 View Controller 。然后根据它是横向还是纵向进行切换。问题是它在纵向模式下工作正常,但由于它在横向模式下将另一个 View 推送到堆栈上,后退按钮链接到纵向 View 而不是我们想要返回的实际屏幕(这是进一步的步骤) .
if (UIDeviceOrientationIsLandscape(deviceOrientation) &&
self.navigationController.visibleViewController == self)
{
self.landscapeViewController =
[self.storyboard instantiateViewControllerWithIdentifier:@"view_landscape"];
[self.navigationController pushViewController:self.landscapeViewController
animated:NO];
}
else if (UIDeviceOrientationIsPortrait(deviceOrientation) &&
self.navigationController.visibleViewController == self.landscapeViewController)
{
[self.navigationController popViewControllerAnimated:NO];
}
我不能以模态方式呈现横向 View Controller ,因为涉及到导航 Controller 。
另一件事是我为每个方向实例化相同的 View Controller (使用相同的类但链接到 Storyboard中的不同标识符)。
最佳答案
您尝试做的事情真的很糟糕,并且违背了 Apple 的做事方式。
有一种称为 Autolayout 的东西,您可以使用它设计一个 View 以在横向和纵向模式下工作。
关于ios - 如何在不将另一个 View Controller 插入堆栈的情况下支持 iOS 7 中的多个屏幕方向?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20263215/