当前位置:编程学习 > wap >>

ios 加入声音效果

 
 
 
在.h文件的生命中
 
    SystemSoundID  soundID;
 
 
 
 
在.m的文件中,第一次执行的DidViewLoad方法里面加入
 
 
 NSString *path = [[NSBundle mainBundle] pathForResource:@"happy" ofType:@"mp3"];
 
AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath:path], &soundID);
 
这两行语句就把对应的音频文件绑定到了相关的SystemSoundID上面了。
 
在需要调用的方法里面加入下面的语句,就可以把声音调用出来了
 
 
 AudioServicesPlaySystemSound (soundEgg); 非常简单好用
 
 
 
 
补充:移动开发 , IOS ,
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,