iOS如何监听用户点击应用图标
AppDelegate.m
- (void)applicationWillResignActive:(UIApplication*)application{
NSLog(@"从应用前台,切换到后台");
}
- (void)applicationDidBecomeActive:(UIApplication*)application{
NSLog(@"点击应用图标,进入打开应用");
}
扩展运行程序的逻辑
//首次运行:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
- (void)applicationDidBecomeActive:(UIApplication *)application
//首次关闭(home):
- (void)applicationWillResignActive:(UIApplication *)application
- (void)applicationDidEnterBackground:(UIApplication *)application
//再次运行:
- (void)applicationWillEnterForeground:(UIApplication *)application
- (void)applicationDidBecomeActive:(UIApplication *)application
//再次关闭:
- (void)applicationWillResignActive:(UIApplication *)application
- (void)applicationDidEnterBackground:(UIApplication *)application
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
NSLog(@"\n ===> 程序开始 !");
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application
{
NSLog(@"\n ===> 程序暂行 !");
}
- (void)applicationDidEnterBackground:(UIApplication *)application
{
NSLog(@"\n ===> 程序进入后台 !");
}
- (void)applicationWillEnterForeground:(UIApplication *)application
{
NSLog(@"\n ===> 程序进入前台 !");
}
- (void)applicationDidBecomeActive:(UIApplication *)application
{
NSLog(@"\n ===> 程序重新激活 !");
}
- (void)applicationWillTerminate:(UIApplication *)application
{
NSLog(@"\n ===> 程序意外暂行 !");
UIDevice *device = [UIDevice currentDevice];
}
网友评论