i am created new project in Xcode6 and added the old files to this project(old files is created in xcode5) ,But whats happening is everything working fine, but "didUpdateToLocation" delegate method is not calling, i also used "didUpdateLocations" delegate method but both are not working.Code i have used from old file but the core location framework has been added from xcode6 ,I don't know what i am missing please anyone guide me to get a solution.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
This question already has answers here:
Closed 5 years ago.
回答1:
If you're testing this on iOS 8 device / Simulator, old location code may not work because of the way the iOS 8 handles Location Services permission access. As of current iOS 8 beta, you need to use new -requestWhenInUseAuthorization
method:
- (void)updateCurrentLocation {
if ([self.locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]) {
[self.locationManager requestWhenInUseAuthorization];
}
[self.locationManager startUpdatingLocation];
}
The user prompt contains the text from the NSLocationWhenInUseUsageDescription
key in your app’s Info.plist file, and the presence of that key is required when calling this method.
<key>NSLocationWhenInUseUsageDescription</key>
<string>We use your location to find places near you.</string>