objective-c - Iphone有内置哔哔声效果吗

标签 objective-c cocoa-touch ios beep

嗨,我需要在 iphone 上使用蜂鸣器,但我唯一找到的就是这个

NSString *soundPath = [[NSBundle mainBundle] pathForResource:@"alert" ofType:@"wav"];

    SystemSoundID soundID;

    AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath: soundPath], &soundID);

    AudioServicesPlaySystemSound (soundID);

    [soundPath release]; 

它正在运行并且代码很好,但我需要导入 alert.wav 文件。但如果存在,我宁愿使用原生(内置)声音来执行此操作。

谢谢大家的回答 CS.

最佳答案

阅读 Apple 和 this 的文档,我几乎可以肯定,您可以在不携带的情况下播放想要的声音。

你可以这样做:

AudioServicesPlaySystemSound(1005);

应该可以。

引用:here

关于objective-c - Iphone有内置哔哔声效果吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5867058/

相关文章:

objective-c - 删除启动屏幕,Xcode 7

cocoa-touch - 使用 NSSortDescriptor 对 NSOrderedSet 进行排序

ios - 在 UitableView 中的 UitableView

ios - 内存中的 AVAudioFile?

ios - 使用 NSJSONSerialization 时从 NSDictionary 获取 null

objective-c - 当多个字段开始编辑时更改 UITextField 背景

iphone - NSXMLParser 分解元音符号 (ä, ö, ü)

ios - 如何使用 Depth Api 去除肖像背景?

c# - 多平台2D游戏引擎

Objective-C block - 用作对象