问题
I am trying to play a button click sound,also that i should be able to manage click sound along with volume button.
What i have done is Added AVFoundationFramework to project,
in .h file
#import <AVFoundation/AVAudioPlayer.h>
#import <AVFoundation/AVFoundation.h>
in .m file under button click method
NSString *soundPath = [[NSBundle mainBundle] pathForResource:@"sound1" ofType:@"mp3"];
NSURL *soundUrl = [NSURL fileURLWithPath:soundPath];
AVAudioPlayer *player = [[AVAudioPlayer alloc] initWithURL:soundUrl];
[player play];
but i get the above error.Any help would be appreciated.
回答1:
It's "initWithContentsOfURL:" not "initWithURL:
".
As in:
AVAudioPlayer *player = [[AVAudioPlayer alloc]
initWithContentsOfURL:soundUrl];
来源:https://stackoverflow.com/questions/20878257/no-visible-interface-for-avaudioplayer-declares-the-selector-initwithurl