【问题标题】:How to get touch/click on a MPMoviePlayerController view when MPMovieControlStyle = MPMovieControlStyleNone当 MPMovieControlStyle = MPMovieControlStyleNone 时如何触摸/单击 MPMoviePlayerController 视图
【发布时间】:2011-06-17 10:46:21
【问题描述】:

在我的一个应用程序中,我不想显示任何视频控制器。但我需要了解媒体播放器视图。我需要在电影播放器​​上进行触摸操作。我该如何实现。请帮忙

提前致谢。

【问题讨论】:

    标签: iphone ipad mpmovieplayercontroller


    【解决方案1】:

    您始终可以将UITapGestureRecognizer 附加到视图并处理水龙头。

    UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)];
    [moviePlayer.view addGestureRecognizer:tap];
    [tap release];
    

    并处理handleTap:中的水龙头

    - (void)handleTap:(UITapGestureRecognizer *)gesture {
        // Do some other action as intended.
    }
    

    当然,这只适用于iOS 3.2 及更高版本。

    【讨论】:

    • 谢谢!!...我试过 TapGuesterRecognizer 但犯了一个小错误。谢谢你纠正我:)
    • 这可能在 iOS 3 以后的版本中实现吗?我的意思是除了GuesterRecognizer。还是我需要子类 MoviePlayerController 来获取触摸事件?。
    • @cherukkayi 在 3.2 之前,控制器占据整个屏幕并自行管理视图。您也不能更改 3.2 之前的 controlStyle 属性。
    • @Deepak,您在上一条评论中所说的内容大多不正确。是的,UIGestureRecognizer 在 iOS 3.2 之前是不存在的(即使在 3.2 中它还是有点测试版)。其余的,MPMoviePlayerController 总是允许删除控件(设置 controlStyle),它只是不支持嵌入式播放。在 3.2 之前识别点击的解决方案是在 MPMoviePlayerController 顶部添加自定义视图并捕获触摸。
    • 我收到了你的最后一份声明。但是没有 controlStyle 属性,是吗?
    【解决方案2】:

    你也可以使用 UIGestureRecognizer 的这个委托方法。

    - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch;
    

    【讨论】:

      猜你喜欢
      • 2011-11-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多