1
-(BOOL)shouldAutorotate {
return NO;
}
上面的方法適用於一個控制器,但是當有多個viewController在堆棧上推送時。
我想要一個特定的控制器,只能以縱向模式顯示。如何在iOS 8中禁用特定控制器的自動旋轉?
- (void) viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator {
}
我已經使用上面的方法建議在iOS 8的堆棧溢出,但它沒有給出預期的結果。
男人,我解決你..你解決了我的問題.... – 2015-09-08 12:23:26
這是做到這一點的正確方法。 但在我的情況下,我也必須重寫NavigationController的[UIViewController shouldAutorotate](繼承它)以返回navigationController.topViewController.shouldAutorotate。 – befstrat 2015-09-15 08:55:00
另外,不要忘記檢查topViewController是否爲空 – henon 2015-10-05 15:13:00