簡體   English   中英

ios9中的力方向

[英]Force orientation in ios9

我想在橫向模式下的2個viewController和1個viewController中強制使用肖像模式,我嘗試了較舊的技術,但是在ios9中不起作用

您很有可能在info.plist定義了一些允許的方向。 您應該檢查那里並刪除所有條目,因為我相信這些條目將覆蓋項目中的所有其他值。

然后,您應該可以使用以下方法在每個VC上設置方向:

-(NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskLandscapeRight;
}

-(BOOL)shouldAutorotate {
return NO;
}

我認為您需要的關鍵是Supported interface orientations

您可以從Xib / Storyboard設置視圖控制器的方向,因為每個視圖控制器都具有屬性“方向”

並實現下面給出的方法

-(BOOL)shouldAutorotate 
{
     return NO;
}

您可以在viewDidAppear方法中將方向設置為波紋管

NSNumber *value = [NSNumber numberWithInt:UIInterfaceOrientationPortrait];
[[UIDevice currentDevice] setValue:value forKey:@"orientation"];

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM