0
- (void)applicationWillBecomeActive:(NSNotification *)notification
{
    NSRunAlertPanel(@"Wee I am called", @"Hello", @"OK", @"Alternate Button", @"OtherButton");


    [showdesktop showDeskHideMe];
}

The problem with code above is it's only launched when the app is first launched.

If after that I open up other apps, and then click the apps again from the dock, the code will not be launched.

How do I do that?

How to "deactivate" an application anyway?

Note: This is about MacOs, not IOS!!!

4

2 回答 2

1

Try the following methods:

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

- (void)applicationDidEnterBackground:(UIApplication *)application
{}

- (void)applicationWillEnterForeground:(UIApplication *)application
{}
于 2012-05-04T09:33:39.443 回答
1

Have a look at the "Notifications" section here: https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/nsapplication_Class/Reference/Reference.htm ( Sorry, can't find a direct link )

There are a bunch of notifications which you can catch ranging a wide array of different events. For example, NSApplicationDidUnhideNotification seems interesting in your case. You can use the NSNotificationCenter to pick up on these notifications. For more information about the NSNotificationCenter check: https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Notifications/Introduction/introNotifications.html#//apple_ref/doc/uid/10000043i

于 2012-05-04T09:37:01.257 回答