我在播放youtube视频时试用力量景观,从UIWebView中加载的移动版youtube执行,我有这个代码,它改变了方向,但是尽管改变了景观,UIMoviePlayer看起来仍然像它一样。 s处于纵向模式。
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(youTubeStarted:) name:@"UIMoviePlayerControllerDidEnterFullscreenNotification" object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(youTubeFinished:) name:@"UIMoviePlayerControllerDidExitFullscreenNotification" object:nil];
-(void)youTubeStarted:(NSNotification *)notification{
NSLog(@"start");
allowrotation = YES;
[[UIDevice currentDevice] setValue:
[NSNumber numberWithInteger: UIInterfaceOrientationLandscapeLeft]
forKey:@"orientation"];
}
-(void)youTubeFinished:(NSNotification *)notification{
NSLog(@"done");
allowrotation = NO;
[[UIDevice currentDevice] setValue:
[NSNumber numberWithInteger: UIInterfaceOrientationPortrait]
forKey:@"orientation"];
}