【问题标题】:Disabling iOS Elastic Scrolling on an embedded YT IFrame在嵌入式 YT IFrame 上禁用 iOS 弹性滚动
【发布时间】:2012-08-03 18:41:19
【问题描述】:

我正在 Adob​​e AIR 中制作面向 iOS 4.0+ 和 Android 2.3+ 的应用程序。我尝试为嵌入的 YT 视频禁用 iOS 弹性滚动:当用户按下播放器的 IFrame 时,整个视频都会平移,我似乎找不到解决方法。

我尝试添加事件侦听器来防止这种行为,但它不起作用。

顺便说一句,我知道我无法真正控制 IFrame 中发生的事情。一个快速而肮脏的解决方案是将元素直接放在框架上,例如透明画布或可以捕获事件的 div。一点也不理想,因为用户将无法按下播放器上的按钮。

有什么想法或建议吗?

谢谢!

【问题讨论】:

    标签: ios iframe air youtube stagewebview


    【解决方案1】:

    我找到了解决办法。

    您需要访问 UIWebView(StageWebView 下的底层 iOS 实现)来禁用弹性滚动。

    一旦您完成了 Adob​​e Native Extension (ANE) 设置,它就相对简单了。 (一个很棒的 ANE 向导/生成器可以在这里找到https://github.com/freshplanet/ANE-Wizard

    对于 iOS 5,它很简单:webView.scrollView.bounces = NO;

    如果您想支持 iOS 4,它会变得有点复杂。你没有webView.scrollView的方便,所以需要手动找到这个视图。

    处理 iOS 4 和 5 的 Objective-C 代码块是这样的:

    NSString *currSysVer = [[UIDevice currentDevice] systemVersion];
    if ([currSysVer compare:@"5.0" options:NSNumericSearch] != NSOrderedAscending) {
        // iOS 5 is straightforward
        webView.scrollView.bounces = NO;
    } 
    else {
      // iOS 4 requires a bit more of work
      UIScrollView *scrollView = nil;
      for (UIView *subview in [webView subviews]) 
      {
        if ([subview isKindOfClass:[UIScrollView class]]) {
          scrollView = (UIScrollView *)subview;
        }
      } 
      if (scrollView != nil) {
        scrollView.bounces = NO;
      }
    }
    

    希望这会有所帮助!

    【讨论】:

      猜你喜欢
      • 2014-07-14
      • 1970-01-01
      • 1970-01-01
      • 2011-12-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-03-07
      • 2014-07-30
      相关资源
      最近更新 更多