2016-09-23 68 views
2

我有一些代碼,我曾經使用presentingViewController.interfaceOrientation來確定當前支持的接口方向UIViewController。由於interfaceOrientation已被棄用,我已經用[[UIApplication sharedApplication] statusBarOrientation]替換了該代碼,它工作正常。但是,在iOS9和iOS8中,它不起作用(當我檢查shouldAutorotateToInterfaceOrientationsupportedInterfaceOrientationspreferredInterfaceOrientationForPresentation中的方向時,我得到了一些非常有趣的結果。確定沒有[[UIApplication sharedApplication] statusBarOrientation] UIViewController的UIInterfaceOrientation?

所以我想知道,有無論如何確定視圖控制器的接口方向而不使用[[UIApplication sharedApplication] statusBarOrientation]? (需要在左右景觀之間進行區分,並將肖像右側上下顛倒)。

+0

檢查方向是你能得到這個答案? –

+0

@DeepakSharma我不記得了。當我查看我的代碼時,我正在使用[[UIApplication sharedApplication] statusBarOrientation],因此不知道我在iOS9和iOS8中修復了這個問題。 –

回答

0

可以使用

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation 
          duration:(NSTimeInterval)duration 
{ 
if (UIInterfaceOrientationIsLandscape(toInterfaceOrientation) == YES) { 
    // landscape 
} 
else { 
    // portrait. 
} 
} 
+0

我試圖避免使用UIDevice來獲取方向,因爲它的行爲與從狀態欄獲取它有點不同。 –

+0

回答更新.. – Ragul

相關問題