【发布时间】:2012-02-24 06:48:24
【问题描述】:
我试图从 tableView 行中提取一个 mp3 文件,当用户单击 tableViewCell 时,我希望该 mp3 文件在 detailView 上播放。但是代码有问题。这是我在 DetailViewController 上的代码:
当我选择行时,我得到一个线程 1:程序接收信号:NSString *file 行的“SIGABRT”。谢谢
- (void)viewDidLoad {
textLabel.text = lullabyLabelString;
NSString *fileName = lullabyMP3String;
NSString *file = [[NSBundle mainBundle] pathForResource:[NSURL fileURLWithPath:fileName] ofType:NULL];
NSError *error = nil;
AVAudioPlayer *theAudio = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:file]error:&error];
theAudio.delegate = self;
[theAudio prepareToPlay];
[theAudio play];
[super viewDidLoad];
}
【问题讨论】:
标签: ios uitableview nsdictionary avaudioplayer