2010-06-07 101 views
1

我有一个视图和一个MPMoviePlayerViewController .. iPad是面向横向左模式,但是当我播放视频时,视频很好看在纵向模式... 有没有一种方法强制movieplayer在横向模式下旋转? 由于事先MPMoviePlayerViewController在iPad视图风景

回答

3

可以强制MPMoviePlayerViewcontroller通过

[player setOrientation:UIDeviceOrientationPortrait animated:NO]; 

在landscapce模式下工作,可以阅读示例代码我的博客文章http://www.makebetterthings.com/blogs/iphone/play-video-on-iphone-and-ipad/

+1

谢谢Saurabh! 我昨天读了你的博客(我也打了电话),但是在哪里显示我跳过的东西,我不知道怎么回事!!!!! 谢谢,我会尽快尝试! – ghiboz 2010-06-08 10:21:30

+1

对不起,但MPMMoviePlayerViewController没有setOrientation方法... https://developer.apple.com/iphone/prerelease/library/documentation/MediaPlayer/Reference/MPMoviePlayerViewController_class/Reference/Reference.html – ghiboz 2010-06-08 20:11:01

+0

对不起,我阅读进入你的博客setOrientation尚未准备好用于iPad ...... – ghiboz 2010-06-08 20:14:27

4
@interface MyMovieViewController : MPMoviePlayerViewController 
@end 

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

@end 

然后只需实例MyMovieViewController代替MPMoviePlayerViewController 。

+0

不要忘记在@interface上面添加#import 。 – Banjer 2010-11-11 19:08:10

+0

但状态栏的位置不变! – Maulik 2011-09-28 05:42:12