永远不会调用iOS 8 CLLocationManagerDelegate方法

编程入门 行业动态 更新时间:2024-10-20 16:32:48
本文介绍了永远不会调用iOS 8 CLLocationManagerDelegate方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

//查看是否加载了方法-分配了LocationManager并将CLLocationManagerDelegate包含在.h文件中

//View did Load Method- LocationManager is allocated and have included the CLLocationManagerDelegate in .h File -ViewDidLoad{ self.locationManager = [[CLLocationManager alloc] init]; self.locationManager.delegate = self; self.locationManager.desiredAccuracy=kCLLocationAccuracyBest; self.locationManager.distanceFilter=kCLDistanceFilterNone; [self.locationManager requestWhenInUseAuthorization]; [self.locationManager startMonitoringSignificantLocationChanges]; [self.locationManager startUpdatingLocation]; } // Location Manager Delegate Methods - (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations { NSLog(@"%@", [locations lastObject]); }

推荐答案

在plist中,您必须添加2个条目

In plist you have to add 2 entries

  • NSLocationWhenInUseUsageDescription
  • NSLocationAlwaysUsageDescription
  • 将两者都设为需要位置才能找到您所在的位置或任何东西

    Make the string of both as "Location is required to find out where you are" or anything

    self.locationManager = [[CLLocationManager alloc]init]; if ([self.locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]) { [self.locationManager requestWhenInUseAuthorization]; } self.locationManager.desiredAccuracy = kCLLocationAccuracyKilometer; CLAuthorizationStatus authorizationStatus= [CLLocationManager authorizationStatus]; if (authorizationStatus == kCLAuthorizationStatusAuthorized || authorizationStatus == kCLAuthorizationStatusAuthorizedAlways || authorizationStatus == kCLAuthorizationStatusAuthorizedWhenInUse) { NSLog(@"You are authorized"); } self.locationManager.delegate = self; [self.locationManager startUpdatingLocation];

    希望这会有所帮助

    更多推荐

    永远不会调用iOS 8 CLLocationManagerDelegate方法

    本文发布于:2023-11-26 20:56:05,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1635161.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:永远不会   方法   iOS   CLLocationManagerDelegate

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!