ios – 没有获得MapKit用户的权限

ios – 没有获得MapKit用户的权限,第1张

概述必须首先调用 – [CLLocationManager requestWhenInUseAuthorization]或 – [CLLocationManager requestAlwaysAuthorization].实际上我已经在Didload中调用了这个方法,甚至在info.plist中添加了这个错误. - (void)viewDidLoad { [super viewDidLoad] 必须首先调用 – [CLLocationManager requestWhenInUseAuthorization]或 – [CLLocationManager requestAlwaysAuthorization].实际上我已经在DIDload中调用了这个方法,甚至在info.pList中添加了这个错误.

- (voID)vIEwDIDLoad {    [super vIEwDIDLoad];    self.navigationItem.Title = @"MapVIEw";    [MapVIEw setMapType:MKMapTypestandard];    [MapVIEw setZoomEnabled:YES];    [MapVIEw setScrollEnabled:YES];    [MapVIEw setShowsUserLocation:YES];    MKCoordinateRegion region = { {0.0,0.0 },{ 0.0,0.0 } };    region.center.latitude = 23.0804 ;    region.center.longitude = 72.5241;    region.span.longitudeDelta = 0.01f;    region.span.latitudeDelta = 0.01f;    [MapVIEw setRegion:region animated:YES];    [MapVIEw setDelegate:self];    CLLocationManager *locationManager = [[CLLocationManager alloc] init];    locationManager.delegate = self;    locationManager.distanceFilter = kCLdistanceFilterNone; //whenever we move    locationManager.desiredAccuracy = kCLLocationAccuracyBest;    [locationManager requestAlwaysAuthorization];    [locationManager requestWhenInUseAuthorization];    [locationManager startUpdatingLocation];    display *ann = [[display alloc] init];    ann.Title = @" Gujarat";    ann.subTitle = @"High Court";    ann.coordinate = region.center;    [MapVIEw addAnnotation:ann];}-(MKAnnotationVIEw *)mapVIEw:(MKMapVIEw *)mV vIEwForAnnotation:(ID <MKAnnotation>)annotation {    MKPinAnnotationVIEw *pinVIEw = nil;    if(annotation != MapVIEw.userLocation)    {        static Nsstring *defaultPinID = @"com.invasivecode.pin";        pinVIEw = (MKPinAnnotationVIEw *)[MapVIEw dequeueReusableAnnotationVIEwWithIDentifIEr:defaultPinID];        if ( pinVIEw == nil ) pinVIEw = [[MKPinAnnotationVIEw alloc]                                         initWithAnnotation:annotation reuseIDentifIEr:defaultPinID];        pinVIEw.pincolor = MKPinAnnotationcolorRed;        pinVIEw.canShowCallout = YES;        pinVIEw.animatesDrop = YES;        pinVIEw.draggable = YES;    }    else {        [MapVIEw.userLocation setTitle:@"I am here"];    }    return pinVIEw;}-(voID)locationManager:(CLLocationManager *)manager dIDChangeAuthorizationStatus:(CLAuthorizationStatus)status{    if (status == kCLAuthorizationStatusAuthorizeDWhenInUse)    {        [locationManager startUpdatingLocation];    }    else if (status == kCLAuthorizationStatusDenIEd)    {        //Alert to show for user if any when status is declined    }    else        NSLog(@"Wrong location status");}

和Annotation的display类

<MKAnnotation> {    CLLocationCoordinate2D coordinate;     Nsstring *Title;     Nsstring *subTitle;}@property (nonatomic,assign) CLLocationCoordinate2D coordinate; @property (nonatomic,copy) Nsstring *Title; @property (nonatomic,copy) Nsstring *subTitle;

这里的代码没有显示用户访问其位置的提示,因此我们没有得到所需位置的位置.亲爱的,从昨天开始帮助我.

解决方法 检查以下应用中的内容.

1)创建CLLocation Manager的类对象.
   如果您创建CLLocation管理器的本地对象,则在用户响应对话框之前释放CLLocationManager对象.

2)转到设置>隐私>位置服务.并检查您的应用是否列在位置服务列表中.如果是,那么点击你的应用程序并进入内部检查开关是否打开.

3)检查requestAlwaysAuthorization:是否支持使用

if ([_locationManager respondsToSelector:@selector(requestAlwaysAuthorization)]) {    [_locationManager requestAlwaysAuthorization];}

4)尝试检查位置管理器的状态

-(voID)checkStatus{CLAuthorizationStatus status = [CLLocationManager authorizationStatus];if (status==kCLAuthorizationStatusNotDetermined) {_status.text = @"Not Determined";}if (status==kCLAuthorizationStatusDenIEd) {_status.text = @"DenIEd";}if (status==kCLAuthorizationStatusRestricted) {_status.text = @"Restricted";}if (status==kCLAuthorizationStatusAuthorizedAlways) {_status.text = @"Always Allowed";}if (status==kCLAuthorizationStatusAuthorizeDWhenInUse) {_status.text = @"When In Use Allowed";  }}

有关详细信息,请访问

1)http://www.devfright.com/location-authorization-ios-8/
2)http://nshipster.com/core-location-in-ios-8/

总结

以上是内存溢出为你收集整理的ios – 没有获得MapKit用户的权限全部内容,希望文章能够帮你解决ios – 没有获得MapKit用户的权限所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1049605.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-25
下一篇2022-05-25

发表评论

登录后才能评论

评论列表(0条)

    保存