How can I add sound to a button in iOS?
问题 I would like to make a sound play when a button is pressed. Also, there is more than one sound. I am using Xcode 4.4.1 and Storyboard. In the .h file { IBOutlet UIButton *playSound; } 回答1: I thought it would be fun to write this type example so I wrote it. It demonstrates how to play different random sound when button is pressed: -(IBAction)buttonPressedWithSound:(id)sender { int randomSoundNumber = arc4random() % 4; //random number from 0 to 3 NSLog(@"random sound number = %i",