iPhone如何查看飞行模式?
你好,
我想检查飞行模式是否打开..如何检查?
谢谢 + 如何检查用户正在使用 WIFI 或 GPRS 或 EDGE。怎么区分??
HI ,
i want to check wether Airplane mode is on or not .. how to check that ?
thanks
+ how to check that the user is using WIFI or GPRS OR EDGE . how to differentiate ??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

发布评论
评论(4)
无语#2024-08-11 19:33:17
这回答了问题的第二部分 - 如何判断用户使用的网络类型(Wifi 或 3g/edge)。它使用 Apple 的可达性代码。将其放入应用程序委托中的 didFinishLaunchingWithOptions 方法中:
Reachability *curReach = [Reachability reachabilityWithHostName: @"www.apple.com"];
NetworkStatus netStatus = [curReach currentReachabilityStatus];
switch (netStatus)
{
case NotReachable:
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Network Status" message:@"Please note: Network access is required to retrieve images." delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
[alert show];
[alert release];
break;
}
case ReachableViaWiFi:
case ReachableViaWWAN:
{
break;
}
}
初雪2024-08-11 19:33:17
对于SDK 3.0
(http://bbs.51pda.cn/simple/?t4861.html)
#import unistd.h
#include dlfcn.h
#include stdio.h
typedef int (*airType)();
static int (*real_air)() = NULL;
int main(int argc, char **argv)
{
int status = 0;
void *libHandle = dlopen("/System/Library/PrivateFrameworks/CoreTelephony.framework/CoreTelephony", RTLD_LAZY);
real_air = (airType)dlsym(libHandle, "CTPowerGetAirplaneMode");
if(! real_air)
{
printf("something wrong");
}
else
{
status = real_air();
}
printf("%d",status);
return status;
}
debian:~#arm-apple-darwin9-gcc -lobjc -bind_at_load
-F"/System/Library/PrivateFrameworks" -framework CoreTelephony test.c -o test
~没有更多了~
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
如果您只想在用户处于飞行模式时显示通知,那么在应用程序的 plist 文件中启用 SBUsesNetwork 属性就足够了。当您的代码使用网络时,系统会提示用户自动关闭飞行模式。
请参阅这篇文章。
If you just want show notification, when user is in airplane mode, then it's enough to enable SBUsesNetwork property in your app's plist file. When your code is using network, user is prompted to turn off Airplane mode automatically.
See e.g. this post.