Location Services not working in iOS 8

前端 未结 26 1979
滥情空心
滥情空心 2020-11-21 10:23

My app that worked fine on iOS 7 doesn\'t work with the iOS 8 SDK.

CLLocationManager doesn\'t return a location, and I don\'t see my app under

26条回答
  •  -上瘾入骨i
    2020-11-21 10:49

            // ** Don't forget to add NSLocationWhenInUseUsageDescription in MyApp-Info.plist and give it a string
    
            self.locationManager = [[CLLocationManager alloc] init];
            self.locationManager.delegate = self;
            // Check for iOS 8. Without this guard the code will crash with "unknown selector" on iOS 7.
            if ([self.locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]) {
                [self.locationManager requestWhenInUseAuthorization];
            }
            [self.locationManager startUpdatingLocation];
    
    
        // Location Manager Delegate Methods    
        - (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
        {
            NSLog(@"%@", [locations lastObject]);
    
    }
    

提交回复
热议问题