【问题标题】:iOS 8 UIWebView MediaPlayer Done Event. How can i get it?iOS 8 UIWebView MediaPlayer 完成事件。我怎么才能得到它?
【发布时间】:2014-09-26 08:57:33
【问题描述】:

在 iOS 7 中,如果我想获取 UIWebView QuickTime“完成”事件。

我可以使用 NSNotification 来获取它。

这是我的代码。

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

使用此功能,我可以在 UIWebView 中获取 Done 事件。

- (void)playerWillExitFullscreen:(NSNotification *)notification

但在iOS 8中,通知不起作用...(通知名称在iOS 7中是隐藏的解决方案。)

那么我怎样才能在 iOS8 中获得它(Done 事件)?

【问题讨论】:

    标签: objective-c uiwebview quicktime uiwebviewdelegate


    【解决方案1】:

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

    -(void)youTubeStarted:(NSNotification *)通知 { //输入的全屏代码在这里.. AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate]; appDelegate.fullScreenVideoIsPlaying = YES; NSLog(@"%f ​​%f",webViewForWebSite.frame.origin.x,webViewForWebSite.frame.origin.y);

    }

    -(void)youTubeFinished:(NSNotification *)notification{ // 左全屏代码在这里... AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate]; 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];
    

    }

    【讨论】:

      猜你喜欢
      • 2011-12-14
      • 2016-05-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-25
      • 1970-01-01
      相关资源
      最近更新 更多