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

时间:2013-10-01 09:29:23

标签: iphone ios orientation

我正在呈现一个在其中播放视频的视图控制器。

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 :(得分:0)

请放下以下方法。我会帮助你

- (BOOL)shouldAutorotate {
    return YES;
}

答案 1 :(得分:0)

尝试应用转换并缩放

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

答案 2 :(得分:0)

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