相关疑难解决方法(0)

iPhone无法使用MPMoviePlayerViewController将电影旋转到横向模式

[更新]

按照建议,我更改了所有父视图控制器以支持所有方向.我的app结构如下:AppDelegate> RootViewController> Videos> VideoDetails> MPMoviePlayerViewController.

如果我改变所有这些以支持所有方向,视频将在风景中播放.但支持所有方向并不是我想要的,并导致其他问题.还有其他工作或我可以做的其他事情吗?

谢谢

[/更新]

我有一个基于肖像的iPhone应用程序,它使用MPMoviePlayerViewController的自定义子类显示视频.当用户按下播放时,我创建了这个类的实例,并按模式呈现它,如下所示:

- (IBAction) playPressed:(id)sender {

NSString *filepath = [[NSBundle mainBundle] pathForResource:self.currentVideoModel.videoFileName ofType:@"m4v"];
NSURL *fileURL = [NSURL fileURLWithPath:filepath];

// MovieViewController is just a simple subclass of MPMoviePlayerViewController
self.moviePlayerController = [[MovieViewController alloc] initWithContentURL:fileURL]; 

// full screen code.
[self.moviePlayerController.moviePlayer setScalingMode:MPMovieScalingModeFill];
[self.moviePlayerController.moviePlayer setFullscreen:TRUE];

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlaybackComplete:) name:MPMoviePlayerPlaybackDidFinishNotification object:self.moviePlayerController];

[self presentMoviePlayerViewControllerAnimated:self.moviePlayerController];
}
Run Code Online (Sandbox Code Playgroud)

问题是它在纵向上播放得很好但是当我将iPhone转为横向时,视频仍然以纵向而非横向播放:(应用中的所有视图控制器仅支持纵向.

我的MPMoviePlayerViewController子类只覆盖以下方法以允许方向更改,但它没有任何影响:

- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
return (toInterfaceOrientation == UIInterfaceOrientationPortrait || toInterfaceOrientation == UIInterfaceOrientationLandscapeRight || toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}
Run Code Online (Sandbox Code Playgroud)

我甚至尝试以编程方式旋转视频,但绝对没有运气,它始终保持纵向模式.

- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation …
Run Code Online (Sandbox Code Playgroud)

iphone movie mpmovieplayercontroller orientation screen-orientation

8
推荐指数
1
解决办法
4894
查看次数

如何实现UIViewController旋转以响应方向更改?

我的应用程序有大约10个不同的UIViewControllers,其中一个我想在旋转设备时切换到横向模式.(其余的,我想保持肖像.)

为了在那个视图上实现旋转,我需要实现其控制器的'shouldAutorotate'方法并返回YES.由于这个视图是通过导航控制器访问的,我还需要创建一个UINavigationController的子类,它实现'shouldAutorotate'并返回YES.

这个解决方案很有效,但也很好.我发现我推到UINavigationController的子类上的所有UIViewControllers都会响应旋转,即使我实现'shouldAutorotate'并返回NO.(记住:我只希望一个特定的UIViewController响应旋转,而不是导航控制器堆栈中的每一个.)

所以,我的问题是:我该如何做到最好?我能提出的所有解决方案似乎都很麻烦,2)更糟糕,似乎没有用.

非常感谢.

iphone uiviewcontroller screen-orientation

7
推荐指数
1
解决办法
1万
查看次数