在我的应用中,所有视图都以Portait
模式打开,但我想更改AVPlayer view
的模式,表示当用户进入此视图时,设备方向会自动更改为{{ 1}}模式。
我使用以下代码实现了这一点。它工作正常,我想通过使用以下代码确认,当我在appstore上传我的应用程序时会有任何问题。
Landscape
答案 0 :(得分:0)
Here您可以找到有关类似问题的简短讨论。他们没有为我工作。这是我的工作。
-(BOOL)shouldAutorotate
{
return true;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscape;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationLandscapeLeft |
UIInterfaceOrientationLandscapeRight;
}
-(void) setSelfOrientation
{
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight];
[self shouldAutorotate];
self.view.transform = CGAffineTransformIdentity;
self.view.transform = CGAffineTransformMakeRotation(M_PI_2);
[self.view setFrame:CGRectMake(0, 0, [[UIScreen mainScreen] bounds].size.height,
[[UIScreen mainScreen] bounds].size.width)];
}
-(void)viewDidDisappear:(BOOL)animated
{
[super viewDidDisappear:animated];
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait]; // rollback previous orientation
[self shouldAutorotate];
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
[self setSelfOrientation];
}