iOS上的捕获硬件按钮时,我的应用程序在后台 [英] Catching hardware buttons on iOS when my app is in background

查看:89
本文介绍了iOS上的捕获硬件按钮时,我的应用程序在后台的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想执行一些code,当用户presses家,权力或音量按钮一(不要紧,它的这些)。

I would like to execute some code when user presses one of home, power or volume buttons(it doesn't matter, which of these).

我想赶上甚至应用程序最小化到后台和设备正在睡觉的事件。

I would like to catch events even application is minimized to background and device is sleeping.

所以首要任务是处理事件,当设备处于用户的口袋,用户presses按钮内,但不取出设备。

So primary task is processing events, when device is inside user's pocket and the user presses button, but not takes out the device.

这可能吗?如果电源按钮isnt't可能的,可能是有可能为体积或家庭按钮?我该怎么办呢?

Is that possible? If it isnt't possible for power button, may be it's possible for volume or home buttons? How can I do it?

推荐答案

您的应用程序无法在iOS设备上的硬件按钮交互。您的应用程序可以接收它已进入后台通知(可能是使用pressing home键的副作用,例如),但也差不多所有

Your application cannot interact with the hardware buttons on an iOS device. Your application can receive notification that it has entered the background (which may be a side-effect of the use pressing the home button, for example) but that is about all

这篇关于iOS上的捕获硬件按钮时,我的应用程序在后台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆