CLLocationmanager delegate method is not working in xcode6 [duplicate]

蹲街弑〆低调 提交于 2019-12-06 00:26:15

问题


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.


回答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>


来源:https://stackoverflow.com/questions/24971981/cllocationmanager-delegate-method-is-not-working-in-xcode6

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!