我試圖通過單擊按鈕播放聲音。但是,當我運行應用程序崩潰,我得到Thread 1 : signal SIGABRT
。我的應用程序在播放聲音時崩潰
這是我的代碼:
.h文件中
#import <AVFoundation/AVFoundation.h>
@interface HljodViewController : UIViewController <AVAudioPlayerDelegate>{
}
-(IBAction)playsound;
.m文件
-(IBAction)playsound {
NSString *path = [[NSBundle mainBundle] pathForResource:@"Geese_4" ofType:@"mp3"];
AVAudioPlayer* theAudio = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
theAudio.numberOfLoops = 1;
[theAudio play];
}
新增了[一般異常斷點(https://developer.apple.com/library/ios/recipes/xcode_help-breakpoint_navigator /articles/adding_an_exception_breakpoint.html#//apple_ref/doc/uid/TP40010433-CH1-SW1)。 – rckoenes