我有一个 UIViewController 驻留在 UINavController 中。通过 AVAudioPlayer 播放音频的 View Controller 。当它被弹出时,它会继续播放音频,即使在 dealloc 方法中我释放了音频播放器。我什至尝试将音频播放器设置为停止/暂停,然后再在 dealloc 中释放它,但它不起作用。
所以,
- 为什么弹出 UIViewController 时不调用 dealloc?
- 我应该使用什么方法在 Controller 弹出之前/之后停止音频播放器。
编辑:我不认为我的 View Controller 被保留在其他地方。这是我分配它并将其推送到导航 Controller 时的代码:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *name = [tableData objectAtIndex:[indexPath row]];
ToquesDetailVC *toqueDetail = [[ToquesDetailVC alloc] initWithNibName:@"ToquesDetail"
audioPath:[[NSBundle mainBundle] pathForResource:name ofType:@"mp4"]
imageNamed:[[NSBundle mainBundle] pathForResource:name ofType:@"jpg"]];
[[self navigationController] pushViewController:toqueDetail animated:YES];
[toqueDetail release];
}
最佳答案
关于第(2)点,您尝试过吗:
- (void)viewDidDisappear:(BOOL)animated
在你的 View Controller 子类上知道它什么时候“消失”?
关于objective-c - 当我的 UIViewController 弹出时调用的方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5967045/