iPhone identify home button pressed

跟風遠走 提交于 2019-12-24 04:56:16

问题


How do I identify if the app was in the background when the home button was clicked and not by external events (sms, call, video call)?


回答1:


If the application is sent to background,

applicationDidEnterBackground 

will be getting called.

If it is by sms, call , video call, then,

applicationWillResignActive

will be getting called first. U can identify with that.




回答2:


AFAIK there's no way. Look at UIApplicationDelegate documentation, you'll see :

- (void)applicationWillResignActive:(UIApplication *)application

This method is called to let your application know that it is about to move from the 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.

There's apparently no way to distinguish an interruption (SMS, call) or an exit (by pushing the Home button).



来源:https://stackoverflow.com/questions/6625134/iphone-identify-home-button-pressed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!