iphone - 在 uiwebview 中播放 youtube 视频。如何处理 "done"按钮?

标签 iphone ios video uiwebview youtube

我有一个播放 youtube 视频的 uiwebview。如何处理完成按钮操作? 现在,当我点击完成按钮时,它会变回我的应用程序主菜单(不是应该关闭的菜单)并且它只是卡住。谁能帮帮我?

Ps:uiwebview所在的菜单,之前是模态呈现的。

最佳答案

YouTube 插件播放器本身就是一个模态视图 Controller 。当完成按钮被按下时,它返回到它的 presentingViewController。它的 presentingViewController 不是模态视图 Controller ,而是调用 [presentModalViewController:animated:] 来呈现模态视图 Controller 的 viewController。由于原始模态视图 Controller 仍处于事件状态,因此该应用的行为很糟糕。

为了解决这个问题,

1) 跟踪模态视图 Controller 是否已呈现但未被关闭。

2) 在呈现 View Controller 的 viewDidAppear 方法中,如果模态视图 Controller 已呈现且未被解除,则解除并再次呈现。

例如,在呈现模态 Web View Controller 的 Controller 中:

 - (void) presentModalWebViewController:(BOOL) animated {
      // Create webViewController here.
      [self presentModalViewController:webViewController animated:animated];
      self.modalWebViewPresented = YES;
  }

  - (void) dismissModalWebViewController:(BOOL) animated {
      self.modalWebViewPresented = NO;
      [self dismissModalViewControllerAnimated:animated];
  }

  - (void) viewDidAppear:(BOOL)animated {
      [super viewDidAppear:animated];
      if (self.modalWebViewPresented) {
           // Note: iOS thinks the previous modal view controller is displayed.
           // It must be dismissed first before a new one can be displayed.  
           // No animation is needed as the YouTube plugin already provides some.
           [self dismissModalWebViewController:NO];
           [self presentModalWebViewController:NO];
      }
  }

关于iphone - 在 uiwebview 中播放 youtube 视频。如何处理 "done"按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8419145/

相关文章:

ios - 捕获 iOS 3D Touch 光标

iphone - 如何在 iPhone 上使用 ffmpeg

ios - 如何为 iPhone 上的 UITableView 创建具有交替颜色的行?

ios - 多种媒体类型的核心数据模型?

ios - Xcode iOS下推按钮,然后在第二个按钮上向上拖动

ios - 如何编辑亮度、对比度和饱和度并为已创建的保存在库中的视频添加字幕?

iphone - 自动显示 MKAnnotation 标注

android - Android 上的 ffmpeg 解码

video - 使用 ffmpeg 进行慢速 VP8 和 VP9 编码

iphone - 在 objective-C (iphone) 中,如何管理 '@protocol' 引用的内存?