将音量摇杆与UISlider同步 [英] Sync Volume rocker with a UISlider

查看:69
本文介绍了将音量摇杆与UISlider同步的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使UISlider与音量摇杆同步.我已经成功使用滑块来更改系统/铃声音量,但是当摇杆移动时,我需要滑块移动.关于如何获取当前体积值的任何建议?我正在使用下面的代码来监视音量变化:

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)];

}

此外,除了铃声"以外,AVSystemController类别还有哪些?

Also, what are the AVSystemController categories other than "Ringtone"?

推荐答案

这将使用音量摇杆更新UISlider:

This will update theUISliderwith the volume rocker:

- (void)volumeChanged:(NSNotification *)notification
{
    AVSystemController *avs = [ notification object ];
    NSString *audioDeviceName;
    [ avs getActiveCategoryVolume:&_volume andName:&audioDeviceName ];
}

这篇关于将音量摇杆与UISlider同步的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆