2013-04-09 120 views
0

假设我关闭了地图中的位置。我去映射。苹果会弹出一些东西,并说该位置不可用。当用户按下设置时,它将转到设置。你如何得到IOS中没有的正常样式位置?

我们如何弹出该消息?

我知道我可以使用UIAlertView。但是,这个消息似乎是苹果的标准。另外,当按下设置时,人们会直接进行设置。我不明白我能做出这样的事情,我的自我还是我能做到的?

看来,苹果只是简单地显示,当我们尝试获取位置时自动弹出,但没有权限这样做。

嗯,不是在我的情况。在我的情况下,如果应用程序没有这样做的权限,它只会挂起等待从未到来的权限。

回答

1

应用程序第一次使用位置服务时,系统会显示该提醒。用户可以选择启用它,但该警报不会再显示。作为开发人员,您也无法再次显示。

你可以做什么,就是检查authorizationStatusCLLocationManager

if ([CLLocationManager authorizationStatus] != kCLAuthorizationStatusAuthorized) { 
    // show alert telling the user to enable location services for this app 
} 

你不能直接打开设置应用虽然。

+0

就是这样。我的应用程序第一次使用位置服务时,系统不显示该警报! – 2013-04-11 06:09:18

0

检查位置服务是否启用。如果没有启用位置服务,请创建一个自己的带有位置服务的UIAlertView按摩。

if([CLLocationManager locationServicesEnabled] && 
    [CLLocationManager authorizationStatus] != kCLAuthorizationStatusDenied) 
{ 
    // Show alert 
} 

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex 
{ 
    if(alertView.tag == 1) 
    { 
     // set Url 
     [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=LOCATION_SERVICES"]]; 


    } 
} 
相关问题