请告诉我你改变Avplayer方向的建议吗?

时间:2014-03-26 07:53:58

标签: ios iphone objective-c

在我的应用中,所有视图都以Portait模式打开,但我想更改AVPlayer view的模式,表示当用户进入此视图时,设备方向会自动更改为{{ 1}}模式。

我使用以下代码实现了这一点。它工作正常,我想通过使用以下代码确认,当我在appstore上传我的应用程序时会有任何问题。

Landscape

1 个答案:

答案 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];
}