1

我向我的 UIViewController 添加了通知以进行捕捉

  - (void)applicationWillResignActive:(UIApplication *)application:

像这样

  - (void)viewDidLoad {

           [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appWillResignActive:)
                                                 name:APP_RESIGN_ACTIVE_NOTIFICATION object:nil];

它工作正常,但如果我像这样显示其他控制器:

[self presentViewController:[[UINavigationController alloc] initWithRootViewController:view]
                   animated:YES
                 completion:nil];

通知停止工作。我只删除通知

 - (void)viewDidUnload {

     [super viewDidUnload];

     [[NSNotificationCenter defaultCenter] removeObserver:self name:APP_RESIGN_ACTIVE_NOTIFICATION object:nil];

但是当我显示模态控制器时它不会被调用。

4

1 回答 1

5

抱歉,我在 Base 类中找到了一个删除通知的地方。

于 2013-08-19T18:46:23.510 回答