i want to know i add sound & image or label on the function of button which is created prgrammatic开发者_如何学Cally on the click of button. firstly my sound was working fy9, but after adding image and label on that same function , sound is not working.
help ME!
Anks.....
try this, worked for me:
in the .h file of the view controller ur using add the "-(IBAction) playSound:(id)sender;" before "@end"
in the .m file of the view controller add the following code:
-(IBAction) playSound:(id)sender{
NSString *path = [[NSBundle mainBundle] pathForResource:@"awh_man" ofType:@"wav"];
AVAudioPlayer* sound =[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
sound.delegate=self;
[sound play];
}
NOTE that you need to add the AVFoundation framework to your project. Good luck.
精彩评论