ios簡單實現如果沒有開啟定位,提示開啟系統軟件定位功能


if([CLLocationManager locationServicesEnabled] && [CLLocationManager authorizationStatus] == kCLAuthorizationStatusDenied) {//判斷該軟件是否開啟定位

        JJLog(@"沒打開");

        self.isAddress = YES;

        UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"打開定位開關" message:@"請點擊設置打開定位服務" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"設置", nil];

        [alertView show];

    }else{

        JJLog(@"打開");

    }

 

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{

  if (buttonIndex == 1) {

          NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];

          if ([[UIApplication sharedApplication] canOpenURL:url]) {

              [[UIApplication sharedApplication] openURL:url];

          }

      }

}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM