检测 MPVolumeView 中的触摸
我正在使用 AVPlayer 复制 MPMediaPlayerView,以便我可以向其添加一些功能。我创建了一个具有播放/暂停功能的 UIView,并在触摸时显示它,然后根据 HeadsUpUI 示例代码设置一个计时器来隐藏它。我向其中添加了 MPVolumeView 来调整音量。
这工作得很好,除了如果你滑动音量时,我的父视图不知道你仍在与子视图交互,并在计时器触发时隐藏自己。所以你仍在调整音量,但滑块已不再存在。
我最想知道的是视图和所有子视图上的触摸何时结束。有办法做到这一点吗?
我能想到的唯一解决方案是遍历 MPVolumeView 的子视图,当我找到滑块时,观察跟踪属性以了解其何时完成跟踪。但这并不能解决有人长时间按住按钮的情况。我真的很想找到一个通用的解决方案。
TIA
I'm replicating an MPMediaPlayerView using AVPlayer so I can add some functionality to it. I've created an UIView with play/pause and I display it on a touch and then set a timer to hide it as per the HeadsUpUI sample code. I've added a MPVolumeView to it to adjust the volume.
That works fine, except that if you're sliding the volume around, my parent view has no idea you are still interacting with a subview and hides itself when the timer fires. So you're still adjusting the volume, but the slider is no longer there.
What I'd ideally like to know is when the touch has ended on the view and all subviews. Is there a way to do this?
The only solution I can think of is to walk the subviews of MPVolumeView and when I find the slider, observe the tracking property to know when it is done tracking. But that doesn't handle someone hold downing on a button for a long time. I'd really like to find a general solution to this.
TIA
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将手势识别器添加到 MPVolumeView。让手势识别器调用您视图中的方法来重置计时器。
Add a gesture recognizer to the MPVolumeView. Have the gesture recognizer call a method in your view that resets the timer.