2011-10-26 57 views
0

當我從視圖中退出,我開始一個順口溜,當我在這個視圖退回我想停止這個順口溜(WMA)IOS:停止音頻,當我在一個視圖返回

,當我退出在IBAction爲我驗證碼:

NSString *path = [NSString stringWithFormat:@"%@/%@", 
        [[NSBundle mainBundle] resourcePath], 
        @"file.wav"]; 

NSURL *filePath = [NSURL fileURLWithPath:path isDirectory:NO]; 

AudioServicesCreateSystemSoundID((CFURLRef)filePath, &soundID); 
AudioServicesPlaySystemSound(soundID); 

但是當我在我嘗試在viewWillAppear中

AudioServicesRemoveSystemSoundCompletion(soundID); 
AudioServicesDisposeSystemSoundID(soundID); 

寫的,但它不工作的視圖返回,你能幫幫我嗎?

回答

0

viewWillAppear:不會在某些情況下被調用。您可以使用通知中心([NSNotificationCenter defaultCenter])或委託讓您查看何時停止播放音樂。 有一些方法,如postNotification:addObserver:,檢查它們。

相關問題