假設self.view使用整個屏幕:
NSURL *url = [[NSBundle mainBundle] URLForResource:@"Robot" withExtension:@"m4v"];
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
moviePlayer.controlStyle = MPMovieControlStyleFullscreen;
moviePlayer.view.transform = CGAffineTransformConcat(moviePlayer.view.transform, CGAffineTransformMakeRotation(M_PI_2));
[moviePlayer.view setFrame: self.view.bounds];
[self.view addSubview: moviePlayer.view];
[moviePlayer play];
現在假設你基本上不想使用當前self.view而只是有它在全屏的工作(我稱之爲; fake-全屏,因爲它不會調用全屏屬性);
NSURL *url = [[NSBundle mainBundle] URLForResource:@"Robot" withExtension:@"m4v"];
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
moviePlayer.controlStyle = MPMovieControlStyleFullscreen;
moviePlayer.view.transform = CGAffineTransformConcat(moviePlayer.view.transform, CGAffineTransformMakeRotation(M_PI_2));
UIWindow *backgroundWindow = [[UIApplication sharedApplication] keyWindow];
[moviePlayer.view setFrame:backgroundWindow.frame];
[backgroundWindow addSubview:moviePlayer.view];
[moviePlayer play];
謝謝!其實,self.view不是全屏。你知道我如何將視頻設置爲全屏嗎? – rottendevice 2011-03-22 20:42:37
哦,等一下,我找到了。 '[moviePlayer setFullscreen:YES animated:YES];' – rottendevice 2011-03-22 20:50:06
哦......再等一等!插入該行可防止視頻在橫向加載。任何想法如何做到這一點? – rottendevice 2011-03-22 21:14:39