我想这样做,当应用程序启动时,应用程序检查iPhone GPS ON或OFF?如果GPS关闭然后app相当。
答案 0 :(得分:4)
您想要了解什么,位置服务或用户是否授予了对位置服务的访问权限? 如果首先,您可以使用:
,而不是取决于iOS版本 iOS 4.x上的:
CLLocationManager *testLocationManager = [[CLLocationManager alloc] init];
BOOL servicesEnabled = [testLocationManager locationServicesEnabled];
[testLocationManager release];
iOS 4.x +上的:
BOOL servicesEnabled = [CLLocationManager locationServicesEnabled];
如果是第二名,那么:
在iOS 4.x上的:没有快速片段,如果 didFailWithError 或 didUpdateToLocation 将被调用,你必须等待,如果是第二,则用户授予访问权限< / p> iOS 4.x +上的
:
BOOL accessGranted = [CLLocationManager authorizationStatus] == kCLAuthorizationStatusAuthorized;
如果没有达到选项,可以轻松使用 exit(0)。是的,请尝试通知用户您要退出应用程序的内容。
答案 1 :(得分:2)
您需要创建CLLocationManager并询问locationServicesEnabled
。这将告诉您位置服务是否可用。
但请注意,Apple不允许应用程序自行退出,用户需要按主页按钮。如果您发现位置服务不可用,则需要告知用户您的应用需要它们,并且应该激活它们以使您的应用正常运行。