jmu*_*phy 7 iphone location mkmapview cllocationmanager
当应用程序第一次尝试获取用户位置时,系统会提示"想要使用您当前的位置",他们可以点击"不允许"或"确定".有没有办法找出用户是否已经确定或不允许?我正在尝试让MKMapView显示用户当前位置,但我想根据用户选择采取不同的操作.
通常你会认为有一个代表来获取这些信息,但似乎没有.
在此先感谢您的帮助.
Jan*_*les 16
您第一次获取用户位置的调用将失败,并显示一条错误消息,告知您用户已拒绝了位置服务.您的CLLocationManagerDelegate方法didFailWithError将被调用,如下所示.(常量定义在CLError.h)
- (void)locationManager:(CLLocationManager*)aManager didFailWithError:(NSError*)anError
{
switch([anError code])
{
case kCLErrorLocationUnknown: // location is currently unknown, but CL will keep trying
break;
case kCLErrorDenied: // CL access has been denied (eg, user declined location use)
message = @"Sorry, flook has to know your location in order to work. You'll be able to see some cards but not find them nearby";
break;
case kCLErrorNetwork: // general, network-related error
message = @"Flook can't find you - please check your network connection or that you are not in airplane mode";
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2479 次 |
| 最近记录: |