[英]Device orientation portrait only for one view controller
I want only portrait orientation only in one view controller. 我只希望在一个视图控制器中纵向放置。 I am doing this :
我正在这样做:
-(BOOL)shouldAutorotate{
return NO;
}
-(NSInteger)supportedInterfaceOrientations:(UIWindow *)window{
// UIInterfaceOrientationMaskLandscape;
// 24
//
// UIInterfaceOrientationMaskLandscapeLeft;
// 16
//
// UIInterfaceOrientationMaskLandscapeRight;
// 8
//
// UIInterfaceOrientationMaskPortrait;
// 2
// return UIInterfaceOrientationMaskLandscape;
return 2;
}
No success !! 没有成功!
I have tried many permutations and combinations as suggested on google but still not working. 我已经尝试过许多建议在Google上进行的排列组合,但仍然无法正常工作。
您应该在shouldAutorotate
返回YES,因为如果您的应用是横向的,在其他情况下您的视图将不会旋转回纵向。
You should try returning YES for shouldAutoRotate to make the below supportedInterfaceOrientations to become effect and also there is no method called -(NSInteger)supportedInterfaceOrientations:(UIWindow *)window on UIViewController instead use: 您应该尝试为shouldAutoRotate返回YES,以使下面的supportedInterfaceOrientations生效,并且在UIViewController上没有名为-(NSInteger)supportedInterfaceOrientations:(UIWindow *)window的方法,而是使用:
This code must go in your view controller which you want to be in portrait only. 此代码必须放在您希望仅以纵向显示的视图控制器中。
-(BOOL)shouldAutorotate
{
return YES;
}
-(NSInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
I'm linking you a post where I answered a question like this. 我正在将您链接到一个帖子,其中我回答了这样的问题。 I hope it will bel helpful
希望对您有所帮助
How to change only one ViewController to landscape mode with UINavigationcontroller 如何使用UINavigationcontroller仅将一个ViewController更改为横向模式
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.