【问题标题】:Vibrate command only works when Settings > Sounds > Vibrate switch is on振动命令仅在“设置”>“声音”>“振动”开关打开时有效
【发布时间】:2012-08-02 03:17:21
【问题描述】:

我正在使用 AudioServicesPlaySystemSound (kSystemSoundID_Vibrate) 来振动手机,但它仅在“设置”>“声音”>“振动”开关打开时才有效。当“设置”>“声音”>“振动”开关关闭可编程性时,如何振动我的手机。我的手机已经越狱了。

谢谢!

【问题讨论】:

    标签: iphone objective-c jailbreak


    【解决方案1】:

    需要打开振动选项开关。

    您需要编辑 com.apple.springboard.plist

    NSString *sbPath = @"/var/mobile/Library/Preferences/com.apple.springboard.plist";
    
    NSMutableDictionary *sbDict = [[NSMutableDictionary alloc] initWithContentsOfFile:sbPath];
    
    [sbDict setValue:[NSNumber numberWithBool:YES] forKey:@"ring-vibrate"];
    [sbDict setValue:[NSNumber numberWithBool:YES] forKey:@"silent-vibrate"];
    [sbDict writeToFile:sbPath atomically:YES];
    
    /* Check to make sure the settings took */
    AudioServicesPlaySystemSound (kSystemSoundID_Vibrate);
    

    您还可以发送通知以更新首选项。我不确定这是否仍然有效。

    notify_post("com.apple.SpringBoard/Prefs");
    

    【讨论】:

    • 感谢您的回答。我想做它的可编程性。
    • 您可以编辑 Springboard 首选项文件。 com.qpple.springboard.plist
    • 谢谢!我以前做过。它只是改变 UI 显示,当 AudioServicesPlaySystemSound (kSystemSoundID_Vibrate) 调用时不能振动手机。我认为这个 plist 描述的是 UI,而不是功能。
    • 无论哪种方式,硬件开关都必须处于 ON 位置。如果它关闭,什么都不会发生。
    猜你喜欢
    • 2012-08-21
    • 2015-08-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多