【发布时间】:2017-10-03 14:39:39
【问题描述】:
如何通过应用程序以编程方式检查系统振动是打开还是关闭? 在我的情况下,UI 设计就像 - 我在 viewcontroller 中设置了一个按钮。哪个功能是,当我按下按钮时,它会提醒我系统振动是打开还是关闭。这是下面的代码。但它不起作用。它总是与其他部分一起使用。
- (IBAction)checkVibrate:(id)sender {
CFStringRef state;
UInt32 propertySize = sizeof(CFStringRef);
AudioSessionInitialize(NULL, NULL, NULL, NULL);
AudioSessionGetProperty(kAudioSessionProperty_AudioRoute, &propertySize, &state);
if(CFStringGetLength(state) == 0)
{
//off
[self Alert:@"It seems that your phone's vibration is off. Please go to your phone setting and make the vibration ON"];
}
else
{
//on
[self Alert:@"It seems that your phone's vibration is On.If you want to off the vibration, please go to device setting and make vibration Off"];
}
}
如果我走错了路,请帮我解决这个问题?
【问题讨论】:
-
@user3182143 ,我知道这是一个重复的问题。但我正在尝试通过 [stackoverflow.com/questions/5519807/….那个时候我没有得到准确的输出。所以请帮帮我
-
我在下面添加了所有来源。
标签: ios objective-c xcode8