我有UINavigationController
堆棧中的所有UIViewController
都是縱向的,除了最後一個橫向。我當前的實現顯示最後一個視圖控制器在縱向上推動,但我可以旋轉到橫向,而不能旋轉回肖像。 如何在推動視圖時強制旋轉到橫向?iOS 6 - 在UINavigationController中強制旋轉UIViewController
我UINavigationController
子類:
@interface RotationViewController : UINavigationController
@end
@implementation RotationViewController
- (BOOL)shouldAutorotate
{
return YES;
}
- (NSUInteger)supportedInterfaceOrientations
{
if (self.topViewController.class == [LoadingViewController class])
{
return UIInterfaceOrientationMaskLandscape;
}
return UIInterfaceOrientationMaskPortrait;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
if (self.topViewController.class == [LoadingViewController class])
{
return UIInterfaceOrientationLandscapeLeft;
}
return UIInterfaceOrientationPortrait;
}
@end
,我想景觀僅視圖控制器:
@implementation LoadingViewController
- (BOOL)shouldAutorotate
{
return YES;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscape;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationLandscapeLeft;
}
@end
其他視圖控制器沒有實現任何的這些方法。
它的工作原理(我只是從我的導航控制器supportedInterfaceOrientation返回0),但我一直在尋找如何觸發自動旋轉時的答案推動視圖。這個解決方案更多是一個招... – 2013-02-28 06:14:38
適合重新定向屏幕!但由於某種原因,狀態欄仍處於最高位置。當我重新調整設備以匹配屏幕時,狀態欄會轉到正確的位置,但是當我回到原始縱向時,屏幕會變成肖像。 (這些都沒有受到'supportedInterfaceOrientation'存在/缺失的影響。) – JohnK 2013-06-21 00:40:12