我如何在iOS中了解飞行模式的开启或关闭 [英] How can i know airplane mode on or off in ios
问题描述
我想检查是否启用布尔型变量的飞行模式.例如:
i would like to check airplane mode on or off on boolean variable. for example :
Bool airplaneMode = airplanemode;
if(airplaneMode)
{
NSLoag(@"Airplane mode on");
}
else
{
NSLoag(@"Airplane mode Off");
}
我不想检查网络是否可用,我只需要检查飞行模式的开或关.
i don't want to check Network is available or not i need only to check airplane mode on or off.
推荐答案
AFAIK,没有内置的api来确定是否启用飞行模式.您必须根据您的应用程序需要检查相应的服务是否可用.
AFAIK, there is no built-in api to determine if Airplane mode is on. You have to check if the respective services are available, depending on what you need in your app.
例如,如果您需要GPS位置,则可以检查GPS位置是否可用,然后处理不同的情况.启用飞行模式后,对于网络连接和所有其他已禁用的服务也是如此.
For example, if you need a GPS location, you could check if a GPS location is available and then handle your different cases. Same for a network connection and all the other services that are disabled when airplane mode is on.
可修复性是检查网络连接的一个示例
Rechability is one example for checking network connection.
这篇关于我如何在iOS中了解飞行模式的开启或关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!