[英]How to check if a view controller is presented modally or pushed on a navigation stack?
[英]Navigation controller stack in landscape mode, but modally presented view controller view always in portrait frame size
我的應用程序主要使用導航控制器堆棧,有時會以模態方式顯示一些控制器。 在橫向模式下,導航控制器堆棧中的控制器工作正常,但是由presentViewController或之前的presentModalViewController顯示的其他視圖控制器始終提供縱向大小視圖框架(在iPad iOS 6.0上始終為768x1024) - 即使在縱向和橫向之間來回旋轉也是如此。
與A視圖控制器相關的一種是橫向模式,但我從縱向模式獲取幀? 但是經過檢查的答案沒有幫助。 如果我將后一個視圖控制器添加為導航堆棧的一部分,則首次加載和后續輪換時發生的調整大小會起作用。 如上所述,當通過presentViewController添加控制器時,問題才會出現。
將模態分支包裝到另一個導航控制器並在那里定義旋轉蒙版。 在iOS6中- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)
shouldAutorotateToInterfaceOrientation - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)
僅適用於導航堆棧分支,整個分支應以相同的方式工作。
因此,導航子類:
@interface CLNotRotatingNavController : UINavigationController
並在其.m中添加此項
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return NO;
}
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskLandscape;
}
- (BOOL) automaticallyForwardAppearanceAndRotationMethodsToChildViewControllers {
return YES;
}
並將所有模態分支包裝到此導航。 這將在必要時鎖定所有內容。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.