每当切换开关时,我想覆盖静音开关以创建新动作。那么切换开关时触发的方法是什么?
谢谢
在 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);