MapKit giving wrong lat & lang - iOS 8

前端 未结 4 1513
星月不相逢
星月不相逢 2021-01-25 22:15

When I try to use map in iOS 8, I get below error.

Trying to start MapKit location updates without prompting for location authorization. Must call -[CLLocationMa         


        
4条回答
  •  庸人自扰
    2021-01-25 22:42

    Not sure what was real problem, but putting below code in viewDidLoad solve problem.

    mapView.delegate = self;
    locationManager.delegate = self;
    self.locationManager = [[CLLocationManager alloc] init];
    #ifdef __IPHONE_8_0
    if(IS_OS_8_OR_LATER) {
         // Use one or the other, not both. Depending on what you put in info.plist
        [self.locationManager requestWhenInUseAuthorization];
    }
    #endif
    [self.locationManager startUpdatingLocation];
    
    mapView.showsUserLocation = YES;
    [mapView setMapType:MKMapTypeStandard];
    [mapView setZoomEnabled:YES];
    [mapView setScrollEnabled:YES];
    

    Reference

提交回复
热议问题