2014-09-26 10 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 

그러나 아이폰 OS 8

알림이 작동하지 않습니다 ...

그래서 내가 어떻게 그것을 (완료 이벤트) iOS8의에서 얻을 수 있습니다 (알림 이름은 아이폰 OS 7의 숨겨진 솔루션입니다)?

답변

-1

[NSNotificationCenter defaultCenter] addObserver : 셀렉터 : @selector (youTubeStarted :) name : UIWindowDidBecomeVisibleNotification object : nil]; [[NSNotificationCenter defaultCenter] addObserver : 셀렉터 : @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]; 

}