2010-07-12 98 views
1

在UIApplication中是否有像beginIgnoringInteractionEvents这样的函数会忽略旋转而不是触摸?我需要我的应用程序不要在我出示的MPMovePlayerViewController中旋转。系统忽略iPhone旋转

感谢

[更新]

这里是我的代码 -

MPMoviePlayerViewController *mpViewController = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:videoURL]]; 
[mpViewController shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationLandscapeRight]; 
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:NO]; 
[self presentMoviePlayerViewControllerAnimated:mpViewController]; 
[mpViewController release]; 

我把它加入两个shouldAutorotateToInterfaceOrientation工作:和setStatusBarOrientation:方法。它在模拟器中工作。但是,如果我在播放视频的同时旋转iPhone,状态栏也会旋转,并保持竖屏方向。在http://i28.tinypic.com/357mrub.png

[UPDATE 2]

通过继承MPMoviePlayerViewController(和实施shouldAutorotate方法)我的问题的

图像,程序转动,它应。只有视频不播放,因为该行

[self presentMoviePlayerViewControllerAnimated:mpViewController]; 

不接受我的子类。

“警告:不相容的Objective-C类型 '结构NoRotate *',预期 '结构MPMoviePlayerViewController *' 时传递参数1 'presentMoviePlayerViewControllerAnimated:' 从不同目标C型”

回答

6

在视图中,目前,实现shouldAutoRotate方法,并简单地返回“NO”。这将导致手机忽略任何和所有方向更改。

+0

它终于成功了!谢谢 – jmont 2010-07-16 05:34:25

0

也许你可以子类MPMoviePlayerViewController这样

// NotRotatingMoviePlayerViewController.h 
@interface NotRotatingMoviePlayerViewController : MPMoviePlayerViewController { 
} 

@end 

// NotRotatingMoviePlayerViewController.m 
@implementation 

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

@end 
+0

谢谢,它只适用于视频不会播放。 [self presentMoviePlayerViewControllerAnimated:mpViewController]; 这是它给我的警告 “警告:当从不同的Objective-C类型传递”presentMoviePlayerViewControllerAnimated:“的参数1时,预期的'struct MPMoviePlayerViewController *'不兼容的Objective-C类型结构NoRotate *' – jmont 2010-07-12 16:20:19