如果我正確理解你的問題,你想shouldAutorotateToInterfaceOrientation得到叫上第二或第三的viewController viewControllers的堆棧上時的設備改變方向。
shouldAutorotateToInterfaceOrientation只在頂級viewController上被調用。如果在第二個或第三個viewController的方法中執行任何佈局代碼,則代碼不會執行。
解決方案很簡單,很多都取決於您的代碼。這是一個應該工作(沒有在Xcode測試)。在你的頂部視圖控制器的shouldAutorotateToInterfaceOrientation方法,添加類似:
for (UIViewController *vc in [self childViewControllers])
{
[vc shouldAutorotateToInterfaceOrientation];
}
如果你有一個指向特定childViewController,你可以專門調用它。從文檔
注:
此方法的實現應該基於interfaceOrientation參數的值簡單地返回YES或NO。不要嘗試獲取interfaceOrientation屬性的值或檢查UIDevice類報告的方向值。您的視圖控制器可以支持某個給定的方向,或者不支持。
做任何佈局,您可以使用:
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
希望這有助於!