首页 文章

呈现视图控制器可将iPhone的方向转换为纵向

提问于
浏览
0

我正在展示一个在其中播放视频的视图控制器 .

enter image description here

当我点击按钮时,视频播放器视图将从故事板启动,其代码如下:

_moviePlayer = [self.storyboard instantiateViewControllerWithIdentifier:@"videoPlayerController"];
[_moviePlayer.view setFrame:self.view.bounds];
[_moviePlayer playMoviesForItems:shopItems];
[self presentViewController:_moviePlayer animated:NO completion:^{
    [self.scrollView scrollRectToVisible:CGRectZero animated:YES];
}];

但是方向转向像这样的肖像:

enter image description here

我在下面编写代码但不起作用:

- (BOOL) shouldAutorotateToInterfaceOrientation:      (UIInterfaceOrientation)toInterfaceOrientation
 {
    return UIInterfaceOrientationIsLandscape(toInterfaceOrientation);
 }


-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskLandscape;
}

iPad没有问题 . 问题出在iPhone上 .

更新:

支持的方向是:

enter image description here

我哪里错了?

3 回答

  • 0

    尝试应用转换并缩放它

    CGAffineTransform aTransform =CGAffineTransformMakeRotation(M_PI_2);
    currentTransform=  CGAffineTransformConcat(aTransform, CGAffineTransformMakeScale(2.0, 2.0));
    
  • 0

    使用preferredInterfaceOrientationForPresentation方法 . 希望它会有所帮助 .

  • 0

    请放下面的方法..我会帮你的

    - (BOOL)shouldAutorotate {
        return YES;
    }
    

相关问题