29,031
社区成员
发帖
与我相关
我的任务
分享
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];
-(void)applicationWillResignActive:(UIApplication *)application
会被调用。按home键前的控制器不会有任何的处理,但你可以通过上述应用程序级的事件处理中发送notification给当前的控制器,让当前的控制器作出处理。