我展示了一个带有以下代码的 MPMovieViewController:
NSString *path = [[NSBundle mainBundle] pathForResource:@"Tutorial" ofType:@"m4v"];
// If path is NULL (the resource does not exist) return to avoid crash
if (path == NULL)
return;
NSURL *url = [NSURL fileURLWithPath:path];
MPMoviePlayerViewController *mpViewController = [[MPMoviePlayerViewController alloc] initWithContentURL:url];
mpViewController.moviePlayer.controlStyle = MPMovieControlStyleFullscreen;
mpViewController.moviePlayer.shouldAutoplay = YES;
// NOTE: This can crash the app in the Simulator. This is a known bug
// in xcode: http://stackoverflow.com/a/8317546/472344
[self presentMoviePlayerViewControllerAnimated:mpViewController];
这在 iOS 4.3 及更高版本中运行良好,但我已经有人在运行 iOS 4.2.1 的设备上对其进行了测试,并且电影播放器视图控制器出现,但立即自行关闭。我在文档中找不到任何可以解释这一点的东西。有没有人有任何想法?