使用 UISlider 同步音量摇杆
我正在尝试让 UISlider 与音量摇杆同步。我已成功使用滑块更改系统/铃声音量,但我需要滑块在摇杆移动时也移动。关于如何获取当前音量值有什么建议吗?我使用下面的代码来监视音量变化:
- (void)volumeChanged:(NSNotification *)notification{
AVSystemController* avc = SharedAVSystemController;
// my sliders name is customVolume, and this is how I
// am trying to get the volume:
customVolume.value = [avc getVolume:(float *) forCategory:(id)];
}
另外,除了“铃声”之外,AVSystemController 类别还有哪些?
I am trying to get a UISlider to sync with the volume rocker. I have successfully used the slider to change the system/ringer volume, but I need the slider to move when the rocker moves. any suggestions on how to get the current volume value? I am using the code below to monnitor the volume change:
- (void)volumeChanged:(NSNotification *)notification{
AVSystemController* avc = SharedAVSystemController;
// my sliders name is customVolume, and this is how I
// am trying to get the volume:
customVolume.value = [avc getVolume:(float *) forCategory:(id)];
}
Also, what are the AVSystemController categories other than "Ringtone"?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
SDK 中有一个类可以自行处理系统音量,MPVolumeView。它不是
UISlider
的子类,因此您无法更改它的外观(好吧,您自己很难将其全部组合在一起),但这可能不是问题。 (编辑:查看类转储,视图包含一个普通的 UISlider 视图,所以它可能比我预期的更容易)我不确定它是否可以处理您需要的所有内容以及它是否适合您的上下文,但您也可以看一下它并尝试一下。
There is a class available in the SDK which handles the system volume all by itself, MPVolumeView. It's not a subclass of
UISlider
therefore you can't change it's appearance (Well, it would be hard hacking it together all by yourself) but that's probably not an issue. (edit: looking at class dumps, the view contains a normalUISlider
view so it may be easier than I expected)I'm not sure whether it handles everything you need and if it will fit in your context, but you can also take a look at it and try it.
这将使用音量摇杆更新
UISlider
:This will update the
UISlider
with the volume rocker: