我的问题是:我的应用程序有一个简短的介绍影片,我想在应用程序启动时显示它,问题是我没有成功。
我在“didFinishLaunchingWithOptions”方法上使用这段代码:
MPMoviePlayerController* moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"launch" ofType:@"mov"]]];
moviePlayer.controlStyle = MPMovieControlStyleNone;
moviePlayer.view.frame = _window.bounds;
moviePlayer.scalingMode = MPMovieScalingModeFill;
[_window addSubview:moviePlayer.view];
[_window makeKeyAndVisible];
//[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlaybackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayer];
[moviePlayer play];
最好的问候
最佳答案
您应该做的是在您的 RootViewController
的 viewDidAppear
方法中删除该代码。或者显示任何其他 View Controller 。这种事情不属于应用程序委托(delegate),您也不应该将 subview 直接添加到您的 UIWindow
实例。
将代码放在 View Controller 中,并将 MPMoviePlayerController
的 View 作为 subview 添加到 self.view
中,它应该可以正常工作。
关于iphone - 从 didFinishLaunchingWithOptions 播放电影,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9622519/