Jin*_*ing 13 iphone cllocationmanager ios4 ios
我知道在iOS 4中不推荐使用属性locationServicesEnabled.相反,我应该调用locationServicesEnabled
在我的app委托方法中
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//Some Code Here...
CLLocationManager *manager = [[CLLocationManager alloc] init];
if (![manager locationServicesEnabled])
{ //show an alert
}
}
Run Code Online (Sandbox Code Playgroud)
我调用了这个方法,然而,Xcode向我显示了一个警告"locationServicesEnabled已被弃用".谁知道如何解决这个问题?由于警告,如果我在系统首选项中关闭了位置服务,则无法显示警报视图.
谢谢!
Emi*_*aez 52
从文档:
locationServicesEnabled:一个布尔值,指示是否在设备上启用了位置服务.(只读)(在iOS 4.0中不推荐使用.请改用locationServicesEnabled类方法.)
所以,而不是[manager locationServicesEnabled]你应该使用[CLLocationManager locationServicesEnabled]
小智 12
如果您只想知道您的应用程序是否有使用GPS的权限,您需要检查[CLLocationManager authorizationStatus]
您可以在CLLocationManager类参考中看到此类方法.
| 归档时间: |
|
| 查看次数: |
18719 次 |
| 最近记录: |