不断检查ios中启用的位置服务 [英] continously check for location services enabled in ios

查看:85
本文介绍了不断检查ios中启用的位置服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个应用程序,其中视图将检查位置服务是否已启用。如果它没有启用,那么它会提示弹出一个但仍然会继续搜索位置但不提示。一旦启用了位置服务,它将继续其过程。

I am trying to make an app in which the view will check whether the location services are enabled or not . If it is not enabled then it will prompt one with a pop up but still it will keep on searching for location but not prompt. As soon as the location services are enabled it will continue its process.

如何做到这一点???

How to do that???

推荐答案

如果禁用了位置服务,则无法继续获取该位置。

You cannot continue getting the location if location service are disabled.

如果您想继续搜索位置,请确保通过检查来启用服务

If you want to continue searching for location be sure that the service is enable by checking

[CLLocationManager locationServicesEnabled]

如果启用,则开始更新位置

If enabled, start updating the location

[locationManager startUpdatingLocation];

然后在

- (void)locationManager:(CLLocationManager *)manager
    didUpdateToLocation:(CLLocation *)newLocation
           fromLocation:(CLLocation *)oldLocation {
    [locationManager stopUpdatingLocation]; // This will stop to check the location
}

删除此代码仍然检查location [locationManager stopUpdatingLocation]; ,但这不是最佳方法,请务必阅读 apple文档以获取该位置的政策

remove this code to still check the location [locationManager stopUpdatingLocation];, but this is not the best approach, be sure to read the apple documentation for the policy of getting the location

这篇关于不断检查ios中启用的位置服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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