简体   繁体   English

ios9中的力方向

[英]Force orientation in ios9

我想在横向模式下的2个viewController和1个viewController中强制使用肖像模式,我尝试了较旧的技术,但是在ios9中不起作用

It's more than likely that you've got some allowed orientations defined in your info.plist . 您很有可能在info.plist定义了一些允许的方向。 You should check there and remove any entries, as I believe these will override any other values in the project. 您应该检查那里并删除所有条目,因为我相信这些条目将覆盖项目中的所有其他值。

You should then be able to set the orientation on each VC with something like: 然后,您应该可以使用以下方法在每个VC上设置方向:

-(NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskLandscapeRight;
}

-(BOOL)shouldAutorotate {
return NO;
}

I think the key you need to is Supported interface orientations . 我认为您需要的关键是Supported interface orientations

You can set the orientation of the viewcontroller from Xib/Storyboard as each viewcontroller have the property "orientation" 您可以从Xib / Storyboard设置视图控制器的方向,因为每个视图控制器都具有属性“方向”

and implement method given below 并实现下面给出的方法

-(BOOL)shouldAutorotate 
{
     return NO;
}

You can set orientation as bellow in your viewDidAppear method 您可以在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