1

UIApplication 中是否有类似 beginIgnoringInteractionEvents 的函数忽略旋转而不是触摸?我需要我的应用程序不要只在MPMovePlayerViewController我展示的内容中旋转。

谢谢

[更新]

这是我的代码——

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

[更新 2]

通过子类化 MPMoviePlayerViewController(并实现 shouldAutorotate 方法),程序可以正常旋转。只有视频不播放,因为线路

[self presentMoviePlayerViewControllerAnimated:mpViewController];

不接受我的子类。

“警告:不兼容的 Objective-C 类型 'struct NoRotate *',当从不同的 Objective-C 类型传递 'presentMoviePlayerViewControllerAnimated:' 的参数 1 时,预期的 'struct MPMoviePlayerViewController *'”

4

2 回答 2

6

在您呈现的视图中,实现 shouldAutoRotate 方法并简单地返回“NO”。这将导致手机忽略任何和所有方向变化。

于 2010-07-12T15:38:27.113 回答
0

也许你可以像这样子类化 MPMoviePlayerViewController

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

@end

// NotRotatingMoviePlayerViewController.m
@implementation

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

@end
于 2010-07-12T15:52:41.573 回答