在iOS5中检测无声模式? [英] Detect Silent mode in iOS5?

查看:141
本文介绍了在iOS5中检测无声模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我过去曾使用过这种方法来检测是否启用了静音开关:

I have used this method in the past to detect if the silent switch is enabled:

- (BOOL)silenced {
    #if TARGET_IPHONE_SIMULATOR
    // return NO in simulator. Code causes crashes for some reason.
    return NO;
    #endif

    CFStringRef state;
    UInt32 propertySize = sizeof(CFStringRef);
    AudioSessionInitialize(NULL, NULL, NULL, NULL);
    AudioSessionGetProperty(kAudioSessionProperty_AudioRoute, &propertySize, &state);

    if(CFStringGetLength(state) > 0)
        return NO;
    else
        return YES;
}

我的iPad或iPhone上的iOS5不再有效。这是一个已知的问题?我无法在堆栈溢出或Apple开发论坛上找到任何答案。

This is no longer working in iOS5 on my iPad or iPhone. Is this a known issue? I haven't been able to find any answers on stack overflow or Apple dev forums.

希望你能帮忙......

Hope you can help...

推荐答案

自iOS 5以来,我们将无法再检测静音开关状态......

We won't be able to detect the silent switch state anymore since iOS 5...

苹果公司的回答是公认的答案:使用AVAudioPlayer检测iPhone的响铃/静音/静音开关不起作用?

The answer from Apple is there on the accepted answer : Detecting the iPhone's Ring / Silent / Mute switch using AVAudioPlayer not working?

这篇关于在iOS5中检测无声模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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