2013-08-05 137 views
4

對於我們的iPad應用程序,我希望允許以橫向模式(不是縱向)自動旋轉屏幕以支持兩種可能的方向。但是,我們的應用程序中有部分應用程序需要將iPad晃動並將iPad移動到方向和方向,這會觸發自動旋轉功能,但不應該。暫時關閉自動屏幕旋轉

是否可以取消和重新激活自動定向,以便在進入應用程序的這部分時鎖定方向並在退出時解鎖?

回答

1

如果特定區間是指另一視圖控制器,是有可能

只需添加這行代碼到控制器..

// which orientation that this view controller support 
- (NSUInteger)supportedInterfaceOrientations 
{ 
    return UIInterfaceOrientationMaskPortrait; 
} 

// prevent rotation 
- (BOOL)shouldAutorotate 
{ 
    return NO; 
} 

// after present this view controller, which orientation do you prefer ? 
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation 
{ 
    return UIInterfaceOrientationPortrait; 
} 
+1

此答案不出現,以解決以激活請求和取消激活屏幕旋轉鎖定 –