简体   繁体   English

在iOS上检测主页按钮按下?

[英]Detecting home button press on iOS?

Is there any way to detect if the user has pressed the home button on iOS? 有没有办法检测用户是否按下iOS上的主页按钮? Obviously if the app is running normally the app delegate methods gets called, but if the device is locked to an app (through Guided Access or an MDM-server) so the app doesn't quit when you push the home button - is there then any way to know if the user pushed it? 显然,如果应用程序正常运行,则会调用应用程序委托方法,但如果设备被锁定到应用程序(通过引导式访问或MDM服务器),那么当您按下主页按钮时应用程序不会退出 - 是吗任何方式来知道用户是否推了它?

My initial thought was to listen for notifications, but I can't seem to see any generated by pressing the home button. 我最初的想法是听取通知,但我似乎无法通过按主页按钮看到任何生成。

short: 短:

no not on a stock idevice 不,不是股票理念

longer: 更长:

on a stock device your best bet is UIApplicationDidEnterBackgroundNotification (Posted when the app enters the background.) 在股票设备上你最好的选择是UIApplicationDidEnterBackgroundNotification (当应用程序进入后台时发布。)


there is no dedicated way to listen for presses to the home button though, so this won't work for GuidedAccess either 虽然没有专门的方法来监听按下主页按钮,但这对GuidedAccess也不起作用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM