xcode - 为什么音频在模拟器中有效,而在我的 iPad 上无效?

标签 xcode ipad ios4 avaudioplayer ios-simulator

我正在努力创建一个非常简单的应用程序。 2个按钮,都播放声音。每个剪辑持续 1 秒并响应“TouchUpInside”。它们是我在 iTunes 中转换的 .caf 文件。

这是我的代码,它再次在模拟器中工作,但在设备上无效:

enter code here- (void)viewDidLoad {

    NSLog(@"InView did load");

AudioServicesCreateSystemSoundID ((CFURLRef)[NSURL fileURLWithPath:[[NSBundle mainBundle]pathForResource:@"bigaif" ofType:@"caf"]], &systemSoundID);


    AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath:[[NSBundle mainBundle] 
                                                                   pathForResource: @"smallwav" ofType:@"wav"]],                                                            
                                                                    &systemSoundIDTwo);

}
-(IBAction) playSound:(id) sender {
AudioServicesPlaySystemSound(systemSoundID);
}

-(IBAction) playSoundTwo:(id) sender {
AudioServicesPlaySystemSound(systemSoundIDTwo);

}

最佳答案

在过去 30 分钟内查找代码中的错误后,我发现 iPad 侧面的静音按钮已打开。在尝试一些奇特的解决方案之前先检查一下。

30 分钟很好用...

关于xcode - 为什么音频在模拟器中有效,而在我的 iPad 上无效?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7411467/

相关文章:

ios - ASIHTTPRequest GET 请求问题

iphone - 在 UItextview 中一次启用滚动属性并禁用(复制、全选、定义)属性

iphone - 动画 :NO 时 pushViewController 不工作

ios - 在包含部署目标 iOS 7.0 及更早版本的应用程序中使用嵌入式框架

iphone - 通用应用程序上 .XIB 中的 UIView 始终报告 iPhone UI 大小

iphone - 是否可以在 iPad 上构建 iPad 应用程序?

iphone - 强制 iPad 应用程序即使在纵向方向也显示 splitView(如设置 iPad 应用程序)

objective-c - 特定关系的核心数据 NSFetchRequest?

ios - RCTBridge 委托(delegate)中的“NSInternalInconsistencyException”失败 - React Native

iphone - 从单个方法实例化一定数量的唯一对象