1

每当切换开关时,我想覆盖静音开关以创建新动作。那么切换开关时触发的方法是什么?

谢谢

4

1 回答 1

1

在 SpringBoard 中钩住这个方法

SBMediaController - (void)setRingerMuted:(char)

如果您只想观察 switch 事件,那么您可以com.apple.springboard.ringerstate像这样使用 darwin 通知中心观察系统范围的通知

static void RingerStateChanged(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo)
{
}

CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(),
                                NULL,
                                RingerStateChanged,
                                CFSTR("com.apple.springboard.ringerstate"),
                                NULL,
                                CFNotificationSuspensionBehaviorDeliverImmediately);
于 2014-10-05T22:36:45.897 回答