Use*_*321 11 iphone gps objective-c ipad ios
我想知道我们可以在iPhone中以编程方式打开/关闭GPS吗?
Mit*_*rie 12
一个简单的例子:
//Init location manager
CLLocationManager* locationManager = [ [ CLLocationManager alloc] init];
locationManager.delegate = self; //we must implement the protocol
//Choose your accuracy level
//To turn on gps (if it isn't on already)
[locationManager startUpdatingLocation];
//To turn gps off (if no other apps are listening)
[locationManager stopUpdatingLocation];
Run Code Online (Sandbox Code Playgroud)
除此之外,你可以监控或多或少的准确性,甚至使用wifi /手机信号塔.请首先阅读示例以获得最佳使用效果.
在iOS 5之前,从第三方应用程序启动手机设置的行为并不一致,但在iOS5中,这种情况有所改善.
如果我们以下面的代码调用startUpdatingLoaction方法,并且如果位置服务关闭,系统警报将弹出,如果我们点击设置按钮,它将导航到手机设置.
CLLocationManager *locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
[locationManager startUpdatingLocation];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11110 次 |
| 最近记录: |