2012-09-13 55 views
1

我们可以通过不关闭应用程序并转到设置页面来调用位置服务警报以重新弹出:类似于某些用户不知道在弹出窗口时是否必须选择“允许或不允许”。问题的解决方案。位置服务警报

+0

你到底在问什么?如果您尝试将用户路由到设置页面以修改其位置访问权限,则不能再执行此操作。看到这个问题:http://stackoverflow.com/questions/9627451/how-to-open-preferences-settings-with-ios-5-1 – johngraham

回答

4

如果您的要求是提醒用户他的位置服务状态,您可以提供自己的警报,并可以导航到用户设置页面。

 - (void) showLocationAlert { 

       if ([CLLocationManager authorizationStatus] != kCLAuthorizationStatusAuthorized) { 

         //Check whether Settings page is openable (iOS 5.1 not allows Settings page to be opened via openURL:) 
         if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"prefs:root=LOCATION_SERVICES"]]) { 
          UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Error" message:@"You must enable location service,Turn on location service to allow \"YourApp\" to determine your location" delegate:self cancelButtonTitle:@"Settings" otherButtonTitles:@"Cancel", nil]; 
          [alert show]; 

         } 
         else { 
          UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Error" message:@"You must enable location service" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil]; 
          [alert show]; 
         } 
       } 
      } 



    - (void) alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { 
      if (buttonIndex == 0) { 
       [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=LOCATION_SERVICES"]]; 
      } 

     } 
+0

谢谢!这可能是我的解决方案 – user1531399

0

不幸的是,这是不可能的,除非设备是越狱。但是,将用户路由到设置窗格中的正确区域相对比较简单。

+0

谢谢你man ^^ – user1531399