gpt4 book ai didi

objective-c - 确定设备是否可以振动 - iPhone 与 iPod Touch

转载 作者:太空狗 更新时间:2023-10-30 03:55:06 24 4
gpt4 key购买 nike

开发一款在特定事件发生时振动的应用。我有一个用于打开或关闭振动选项的设置。

我希望能够为 iPod Touch 等没有振动功能的设备禁用振动设置的显示。我知道我可以通过使用以下方法确定设备型号来做到这一点:

UIDevice *thisDevice = [UIDevice currentDevice];
modelOfDevice = [thisDevice model];

然后我可以根据 modelOfDevice.. 禁用振动选项(即不为 iPod Touch 显示它)。这行得通 - 但是,我认为这是一种糟糕的形式。例如,如果 future 的 iPod Touch 设备确实包含振动功能,则此解决方案将会失败。

那么,问题是……如何检查设备是否具有振动功能?

任何建议表示赞赏。提前致谢。

最佳答案

如果您只使用 AudioServicesPlaySystemSound(kSystemSoundID_Vibrate),它会在它能振动的地方振动,而在它不能振动的地方不振动——正如 Apple 文档所说,因此您可以跳过检测。[article][1] 说只是可以让 AudioServicesPlayAlertSound(kSystemSoundID_Vibrate) 在可能的地方振动或在没有的地方发出哔哔声(iPod Touch 仍然具有哔哔声/按键点击声音功能)

[1]: http://blog.mugunthkumar.com/coding/iphone-tutorial-better-way-to-check-capabilities-of-ios-devices/文章

关于objective-c - 确定设备是否可以振动 - iPhone 与 iPod Touch,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2527147/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com