objective-c - 当我的 UIViewController 弹出时调用的方法?

标签 objective-c cocoa-touch uiviewcontroller uinavigationcontroller avaudioplayer

我有一个 UIViewController 驻留在 UINavController 中。通过 AVAudioPlayer 播放音频的 View Controller 。当它被弹出时,它会继续播放音频,即使在 dealloc 方法中我释放了音频播放器。我什至尝试将音频播放器设置为停止/暂停,然后再在 dealloc 中释放它,但它不起作用。

所以,

  1. 为什么弹出 UIViewController 时不调用 dealloc?
  2. 我应该使用什么方法在 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/

相关文章:

objective-c - NSView 的边界与框架

iphone - 如何在 iPhone 中创建登录屏幕(作为 UIAlertView)?

iphone - 如何以编程方式布局在不同 "modes"之间切换的应用程序?

ios - 如何将 UITableViewCell 放到 UITableView 的底部。

ios - 如何将 SKNode 渲染到 UIImage

ios - 第二次加载 ViewController 时,self.navigationController 为 nil

ios - 知道推送的 viewController 是否可见

ios - iOS 7 中的自定义 UIView 方向问题

objective-c - iOS NSKeyedUnarchiver 调用单例 getter

iphone - iOS Root View Controller 的 viewDidAppear : called while splash screen (Default. png) 仍然在屏幕上