-(IBAction)voiceBroadcast
{
if ([audioPlayer isPlaying]) {
[audioPlayer stop];
[NSObject cancelPreviousPerformRequestsWithTarget:self];
}
else {
if (nil != audioPlayer) {
[audioPlayer play];
audioPlayer.volume = 0.0;
[self performSelector:@selector(doBgMusicFadeIn)];
[self performSelector:@selector(doBgMusicFadeDown) withObject:nil afterDelay:3];
[self performSelector:@selector(startVoiceBroadcast) withObject:nil afterDelay:4];
}
}
}
-(void)dealloc
{
//position
[NSObject cancelPreviousPerformRequestsWithTarget:self];
[super dealloc];
}
的cancelPreviousPerformRequestsWithTarget:self
在dealloc
工作叫,但不工作時,選擇仍可以調用。但cancelPreviousPerformRequestsWithTarget:self
在voiceBroadcast
沒有問題。 cancelPreviousPerformRequestsWithTarget
方法不能用於dealloc
?cancelPreviousPerformRequestsWithTarget不dealloc的
它不工作,這種方法「[NSObject的cancelPreviousPerformRequestsWithTarget:個體經營]。不執行,但感謝你的幫助,畢竟 – Fannic
也許theese方法('-dealloc' ,'-viewDidUnload')沒有被執行?把一些NSLogs放在那裏,告訴我是否在控制檯中有輸出。 – akashivskyy
dealloc被執行,並且cancelPreviousPerformRequestsWithTarget:self在dealloc中也被執行,但它不起作用。 viewDidUnload不會被執行 – Fannic