2014-09-26 68 views
-1

在iOS 7中,如果我想獲取UIWebView QuickTime「完成」事件。iOS 8 UIWebView MediaPlayer完成事件。我怎麼才能得到它?

我可以使用NSNotification來獲取它。

這是我的代碼。

[[NSNotificationCenter defaultCenter] addObserver:self 
             selector:@selector(playerWillExitFullscreen:) 
              name:@"UIMoviePlayerControllerWillExitFullscreenNotification" 
              object:nil]; 
[_videoWebView loadRequest:[NSURLRequest requestWithURL:_contentURL]]; 

並使用此函數,我可以在UIWebView中獲取完成事件。

- (void)playerWillExitFullscreen:(NSNotification *)notification 

但在iOS 8的,通知是不行的...(通知名稱是iOS的7隱藏的解決方案)

那麼如何才能得到它(完成事件)在iOS8上?

回答

-1

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(youTubeStarted :) name:UIWindowDidBecomeVisibleNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(youTubeFinished :) name:UIWindowDidBecomeHiddenNotification object:nil];

- (無效)youTubeStarted:(NSNotification *)通知 { //進入全屏代碼到這裏.. 的AppDelegate *的appDelegate =(AppDelegate中*)[[UIApplication的sharedApplication]委託]; appDelegate.fullScreenVideoIsPlaying = YES; NSLog(@「%f%f」,webViewForWebSite.frame.origin.x,webViewForWebSite.frame.origin.y);

}

- (無效)youTubeFinished:(NSNotification *)通知{ //左全屏代碼到這裏... 的AppDelegate *的appDelegate =(AppDelegate中*)[[UIApplication的sharedApplication]委託]; appDelegate.fullScreenVideoIsPlaying = NO;

//CODE BELOW FORCES APP BACK TO PORTRAIT ORIENTATION ONCE YOU LEAVE VIDEO. 
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait animated:NO]; 
//present/dismiss viewcontroller in order to activate rotating. 
UIViewController *mVC = [[UIViewController alloc] init]; 
[self presentViewController:mVC animated:NO completion:Nil]; 
// [self presentModalViewController:mVC animated:NO]; 
[self dismissViewControllerAnimated:NO completion:Nil]; 
// [self dismissModalViewControllerAnimated:NO]; 

}