我向我的 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];
但是当我显示模态控制器时它不会被调用。