gpt4 book ai didi

ios - 让 iPhone 振动

转载 作者:IT王子 更新时间:2023-10-29 07:25:31 29 4
gpt4 key购买 nike

iPhone如何设置振动一次?

例如,当玩家失去生命或游戏结束时,iPhone 应该振动。

最佳答案

来自“iPhone Tutorial: Better way to check capabilities of iOS devices”:

有两个看似相似的函数都带有一个参数kSystemSoundID_Vibrate:

1) AudioServicesPlayAlertSound(kSystemSoundID_Vibrate);
2) AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);

Both of the functions vibrate the iPhone. But, when you use the first function on devices that don’t support vibration, it plays a beep sound. The second function, on the other hand, does nothing on unsupported devices. So if you are going to vibrate the device continuously, as an alert, common sense says, use function 2.

首先,将 AudioToolbox 框架 AudioToolbox.framework 添加到构建阶段中的目标。

然后,导入这个头文件:

#import <AudioToolbox/AudioServices.h>

关于ios - 让 iPhone 振动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4724980/

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