![](/img/trans.png)
[英]iPad UIViewController loads as portrait when device is in landscape
[英]init a UIViewController in portrait and landscape
我有一個帶有xib的UIViewController,每當我分配它時,UIViewController的視圖和寬度都不會隨我所處的方向調整,它始終設置為縱向。 即使我在風景。 為什么是這樣? 這是我如何初始化它:
PNRWebViewController *wvController = [[PNRWebViewController alloc] initWithNibName:@"PNRWebViewController" bundle:nil];
[self.view addSubview:self.webViewController_.view];
發生這種情況的原因有很多。 查看有關此主題的官方《 Apple Q&A指南》:
視圖控制器不實現此委托方法:(BOOL)應該AutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation;
視圖控制器的UIView屬性嵌入在UIWindow中,但與其他視圖控制器一起。
您已經將視圖控制器的UIView屬性添加為UIWindow作為子視圖,但是此后不久就過早釋放了它。
UITabBarController或UINavigationController中的所有子視圖控制器在通用方向集上均不一致。
覆蓋-(id)init:
或-(id)initWithNibName:(NSString *)nibName bundle:(NSBundle *)nibBundle
方法,而不調用super。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.