我在UIPopoverController中有一個視圖控制器。我想根據它是否在縱向方向來調整UI。UIPopoverController中的UIViewController總是報告爲處於肖像模式
無論我的iPad在什麼方向(物理設備),self.interfaceOrientation總是報告肖像。我將它記錄在-viewWillAppear中:它始終是Portrait。
爲什麼?
我在UIPopoverController中有一個視圖控制器。我想根據它是否在縱向方向來調整UI。UIPopoverController中的UIViewController總是報告爲處於肖像模式
無論我的iPad在什麼方向(物理設備),self.interfaceOrientation總是報告肖像。我將它記錄在-viewWillAppear中:它始終是Portrait。
爲什麼?
用途:
UIInterfaceOrientation deviceOrientation = [UIApplication sharedApplication].statusBarOrientation;
識別的狀態欄。oriantation。
彈出窗口中的視圖控制器始終處於縱向狀態。無論設備以何種方式放置,popover的方向始終是縱向。
如果您希望根據設備的方向在視圖控制器中執行不同的操作,請查看UIApplication statusBarOrientation
。
想象彈出如下重力。它總是指向下。
您的帖子中有錯誤。 'statusBarOrientation'類型爲'UIInterfaceOrientation',而不是'UIDeviceOrientation'。 – rmaddy
編輯後仍然不正確。 – rmaddy
似乎在編輯之後工作得很好:UIInterfaceOrientationIsLandscape([UIApplication sharedApplication] .statusBarOrientation) – JasonD