iPhone - 我如何知道振动是否开启或关闭iOS? [英] iPhone - How do I know if the vibrate is on or off for iOS?

查看:171
本文介绍了iPhone - 我如何知道振动是否开启或关闭iOS?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你知道我怎么知道iPhone是否处于振动模式?
我在网上找不到任何内容...太累了看看?

Do you know how I may know if the iPhone is on vibrate mode ? I don't find anything about this on the Web... Too tired to see ?

我想在应用程序中显示一个图标,如果手机处于振动模式,用户可以知道看到它。 Tha应用程式也有不同的行为,取决于使用者是否要受到干扰(振动关闭)或不振动(振动)。

I want to display an icon in the app so that the user can know looking at it if the phone is on vibrate mode or not. Tha app has also different behaviours depending on if the user wants to be disturbed (vibrate off) or not (vibrate on).

谢谢。

推荐答案

您应该能够使用:

#import "AudioToolbox/AudioToolbox.h"

- (void) ifSilentModeThenShowIcon
{
   CFStringRef state;
   UInt32 propertySize = sizeof(CFStringRef);
   AudioSessionInitialize(NULL, NULL, NULL, NULL);
   AudioSessionGetProperty(kAudioSessionProperty_AudioRoute, &propertySize, &state);

   if(CFStringGetLength(state) == 0)
   { 
     // phone's ringer is off so put
     // some icon showing code here
   }
}

来源

这篇关于iPhone - 我如何知道振动是否开启或关闭iOS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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