Reply:
If it is returned to the main screen, press the home button, only to wake up again respond when the application-level processing. appdelegate.h file
- (void) applicationWillResignActive: (UIApplication *) application
Will be called. Press the home button controller does not have any pre-treatment, but you can through the above application-level event handler to send notification to the current controller, so that the current controller to handle it.
Reply:
Send notification to the current controller, specifically how to do, to demonstrate under it?
Reply:
Haha already get to know it. . . The easiest way is to call a function
ViewController * controller = (ViewController *) (self.window.rootViewController);
[Controller test];
nocication can use the following code
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];
No comments:
Post a Comment