在ios中区分主页按钮点击和来电?

是否有任何解决方案可以区分手动退出应用程序(通过主页按钮单击)和通过来电退出应用程序?

请帮忙!!!

是的,有点。

单击主页按钮或关闭屏幕将导致您的应用程序被置于后台( applicationDidEnterBackground ),而电话则不会,并且只会让您的应用程序重新启动其活动状态( applicationWillResignActive )。

但是,其他操作(如提高多任务栏)也会导致应用程序辞职。

您无法处理主页按钮单击。 但是当用户点击主页按钮或点击应用程序图标后,会调用应用程序的 委托方法。 你可以编写代码。

 - (void)applicationWillResignActive:(UIApplication *)application { /* Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. */ } - (void)applicationDidEnterBackground:(UIApplication *)application { /* Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. */ } - (void)applicationWillEnterForeground:(UIApplication *)application { /* Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. */ } - (void)applicationDidBecomeActive:(UIApplication *)application { /* Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. */ } - (void)applicationWillTerminate:(UIApplication *)application { /* Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. */ } 

它可以帮助您解决旅游问题。