从webView(仅限肖像应用程序)执行UIMoviePlayer中的强制格局

时间:2014-07-28 17:15:20

标签: ios objective-c iphone uiwebview youtube

我在播放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"];
}

0 个答案:

没有答案