【发布时间】:2017-09-16 12:58:39
【问题描述】:
我的应用程序同时支持纵向和横向方向。我正在使用以下代码从位于 UITabBarController 中的 UIViewController 模态地呈现 UIViewController:
self.modalViewController = [[ModalViewController alloc] init];
[self presentViewController:self.modalViewController animated:YES completion:^{
}];
ModalViewController 是一个控制器,只能由用户在 Landscape 中看到。它应该能够从 LandscapeRight 旋转到 LandscapeLeft。看起来是这样的:
@implementation ModalViewController
#pragma mark - UIViewController - Orientation
- (UIInterfaceOrientationMask)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscape;
}
- (BOOL)shouldAutorotate
{
return YES;
}
#pragma mark - NSObject
- (void)viewDidLoad
{
[super viewDidLoad];
self.view.backgroundColor = [UIColor greenColor];
}
#pragma mark - UIViewController - Status Bar
- (BOOL)prefersStatusBarHidden
{
return YES;
}
@end
控制器从左侧向上滑动并在 95% 的时间内完全覆盖屏幕。但有 5% 的情况下,它会从底部向上滑动,只覆盖屏幕的上半部分。
这是它正常工作时的样子:
以下是它无法正常工作时的样子:
我创建了一个示例项目,可以在这里找到:https://github.com/TitouanVanBelle/Bug
有一个 UI 测试目标可以帮助重现该问题,但它很少起作用。
有人知道为什么会这样吗?
【问题讨论】:
-
感谢发帖,也在寻求解决方案
标签: ios objective-c uiviewcontroller