0
我有一個支持橫向和縱向模式的分割視圖控制器。當詳細視圖控制器處於特定視圖時,我將禁用縱向並僅允許橫向方向。但是,如果用戶離開該特定視圖,將該設備旋轉爲縱向,然後返回到該特定視圖,該縱向仍然是縱向。我需要它自動旋轉回風景。以下是我正在使用的。這些方法都是從我的子類UISplitViewController中調用的,以便方向可以取決於視圖控制器。iOS強制splitViewController旋轉到橫向
#pragma mark - Orientation
- (BOOL)shouldAutorotate
{
// Allow view controller to rotate between landscapes
return YES;
}
- (NSUInteger)supportedInterfaceOrientations
{
// Return supported interface orientation
return UIInterfaceOrientationMaskLandscape;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
// Return preferred orientation
return UIInterfaceOrientationLandscapeLeft;
}