我有一個矩形按鈕,當用戶按下它一次。聲音播放 但我想要它,所以當用戶雙擊按鈕時,聲音連續循環直到用戶決定按下停止聲音。 這是播放聲音的代碼。循環可可觸摸中的聲音
- (IBAction)oneSound:(id)sender; {
NSString *path = [[NSBundle mainBundle] pathForResource:@"1" ofType:@"wav"];
if (theAudio) [theAudio release];
NSError *error = nil;
theAudio = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:&error];
if (error)
NSLog(@"%@",[error localizedDescription]);
theAudio.delegate = self;
[theAudio play];
}
謝謝!
這與Xcode沒有任何關係(並且它是_is_「Xcode」,而不是「xCode」)。我會爲你重新設計。 – 2011-04-17 18:06:06
很抱歉!史蒂夫喬布斯會殺了我,如果他看到了這一點。 – LAA 2011-04-17 18:49:10