iPhone - 捕获设备按钮按下 [英] iPhone - Capture device button push
本文介绍了iPhone - 捕获设备按钮按下的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道您无法在应用程序中控制设备音量,但我希望设备音量能够影响我在应用程序中控制音量的UIScrollBar。
I know you cannot control device volume from within your application, but I would like the device volume to be able to affect the UIScrollBar I have in my application to control volume.
我知道这是可能的,因为Last.fm应用程序会这样做,我想实现这种行为。
I know this is possible because the Last.fm application does it, I would like to implement this behaviour.
我几乎找不到关于互联网的信息。这里的任何人都可以帮助我吗? :)
I can find very little information on the interwebs. Anyone here can help me maybe? :)
推荐答案
听众回调很容易
void audioVolumeChangeListenerCallback (void *inUserData, AudioSessionPropertyID inID, UInt32 inDataSize, const void *inData)
{
RootViewController *controller = (RootViewController *) inUserData;
Float32 newGain = *(Float32 *)inData;
[controller setGainManual:newGain];
}
在我的视图控制器的viewDidLoad中初始化,如下所示
which gets initialized in my view controller's viewDidLoad like this
AudioSessionAddPropertyListener (kAudioSessionProperty_CurrentHardwareOutputVolume ,audioVolumeChangeListenerCallback, self );
这也是所有SDK / App Store友好的。
This is all SDK/App Store friendly too.
这篇关于iPhone - 捕获设备按钮按下的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文