xcode 4.2音板? [英] xcode 4.2 soundboard?

查看:115
本文介绍了xcode 4.2音板?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好我一直试图创建一个音板一段时间,我发现这个网站有人可以通过为iPhone Xcode 4.2提供一个完整工作的代码来回答这个问题谢谢你的时间。

hi all i have been trying to create a soundboard for some time and i found this site is there anyone out there that can answer this question by putting up a fully working code for iPhone Xcode 4.2 thank you for your time.

继承我的代码,但它有错误

heres my code but it has errors

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController 

-(IBAction)sound1 {
    CFBundleRef mainBundle = CFBundleGetMainBundle();
    CFURLRef soundFileURLRef;
    soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef) @"sound1", CFSTR      ("wav"), NULL);

    UInt32 soundID;
    AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID);
    AudioServicesPlaySystemSound(soundID);
}

加上某人说使用av的东西请编辑或上传代码回答时我初学者lol

plus someone said to use av something please edit or upload code When answering I'm a beginner lol

推荐答案

我刚刚测试了你发布的代码,它的工作原理非常好 - 这里没有错误。

I just tested the code you posted and it works very well as is - no errors here.

所以你可能忘记做一件(或多件)以下事情:

So you probably forgot to do one (or more) of the following things:


  • 在项目中包含 AudioToolbox 框架

  • #import< AudioToolbox / AudioToolbox.h> ;;

  • 将sound1.wav文件添加到您的项目中

  • 检查sound1.wav是否真的是sound1。 wav而不是Sound1.wav或类似

  • 将您的IBAction方法连接到一些真正被触发的事件

  • include AudioToolbox framework into your project
  • #import <AudioToolbox/AudioToolbox.h>; in your ViewController.m file
  • add sound1.wav file to your project
  • check that sound1.wav is really sound1.wav and not Sound1.wav or similiar
  • connect your IBAction method to some event that really gets triggered

这篇关于xcode 4.2音板?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆