如果是按home键回到主屏幕,再次换醒时只会响应应用程序级的处理。appdelegate.h文件中
-(void)applicationWillResignActive:(UIApplication *)application 
会被调用。按home键前的控制器不会有任何的处理,但你可以通过上述应用程序级的事件处理中发送notification给当前的控制器,让当前的控制器作出处理。

解决方案 »

  1.   

    发送notification给当前的控制器,具体怎么做,能演示下吗?
      

  2.   

    哈哈 已经搞懂了最简单的方法是调用函数ViewController *controller=(ViewController *)(self.window.rootViewController);
    [controller test];nocication可以用下面的代码
        NSNotification *ntf = [NSNotification notificationWithName:@"chgValue" object:self];
        
        NSNotificationCenter *ntfCenter = [NSNotificationCenter defaultCenter];
        
        ViewController *controller=(ViewController *)(self.window.rootViewController);
     
        [ntfCenter addObserver:controller selector:@selector(getNtf:) name:@"chgValue" object:self];
        
        [[NSNotificationQueue defaultQueue]enqueueNotification:ntf postingStyle:NSPostNow coalesceMask:NSNotificationCoalescingOnName forModes:nil];