【发布时间】:2015-05-19 19:44:38
【问题描述】:
我有 2 个视图控制器:ViewControllerA 和 ViewCorollerB。
ViewControllerA 仅支持横向左/右。
这些是 ViewControllerA.m 中的一些方法:
- (BOOL)shouldAutorotate{
return YES;
}
- (NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskLandscape;
}
-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{
return UIInterfaceOrientationLandscapeRight;
}
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation{
[self settingLayoutForOrient:[[UIApplication sharedApplication] statusBarOrientation]];
}
在ViewControllerA中调用后续代码时显示ViewControllerB:
ViewControllerB *control = [[ViewControllerB alloc] init];
[self presentViewController:control animated:NO completion:nil];
ViewControllerB 支持全方向。
这些是 ViewControllerB.m 中的一些方法:
- (BOOL)shouldAutorotate{
return YES;
}
- (NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskAll;
}
- (void)didRotateFromInterfaceOrientation: (UIInterfaceOrientation)fromInterfaceOrientation{
[self settingLayoutForOrient:[[UIApplication sharedApplication] statusBarOrientation]];
}
请帮我回答以下问题:
- 从 ViewControllerA 和处于纵向模式的设备转到 ViewControllerB。为什么第一次出现 ViewControllerB,状态方向总是横向左/右,而设备处于纵向模式?
2.ViewControllerB第一次出现时,如何在每种情况下(portrait、portraitUpsideDown、FaceUp、FaceDown、横向左、横向右)获取状态栏的准确方向?
感谢您的帮助。
【问题讨论】:
标签: ios orientation