我有2個視圖控制器:ViewControllerA和ViewCotrollerB。如何確定視圖控制器的界面方向?
ViewControllerA只支持橫向左/右。
這些都是一些方法ViewControllerA.m:
ViewControllerB *control = [[ViewControllerB alloc] init];
[self presentViewController:control animated:NO completion:nil];
ViewControllerB支持全方向:
- (BOOL)shouldAutorotate{
return YES;
}
- (NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskLandscape;
}
-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{
return UIInterfaceOrientationLandscapeRight;
}
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation{
[self settingLayoutForOrient:[[UIApplication sharedApplication] statusBarOrientation]];
}
ViewControllerB當ViewControllerA呼叫跟蹤代碼顯示。
這些都是一些方法ViewControllerB.m:
- (BOOL)shouldAutorotate{
return YES;
}
- (NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskAll;
}
- (void)didRotateFromInterfaceOrientation: (UIInterfaceOrientation)fromInterfaceOrientation{
[self settingLayoutForOrient:[[UIApplication sharedApplication] statusBarOrientation]];
}
請幫我在下面回答問題:
- 從ViewControllerA和設備在人像模式,去ViewControllerB。爲什麼在第一次ViewControllerB apprear時,狀態的方向總是左右/左右,儘管設備處於縱向模式?
2.如何在ViewControllerB中第一次出現ViewControllerB時,在每種情況下(縱向,縱向,下方,面朝上,朝下,橫向向左,橫向向右)輕鬆實現狀態欄的朝向?
感謝您的幫助。
嗨Paras vora,我不使用故事板,也不使用UINavigationController。 – Khoi