检测ios的用户是否拒绝开启默认位置的实现
本帖最后由 CSDN_Ask 于 2013-01-31 10:52:44 编辑 原问题来自于CSDN问答频道,更多解决方案见:http://ask.csdn.net/questions/1295
原问题描述:
请问一下,检测ios的用户是否拒绝开启默认位置,能实现么?
我需要在实现检测结果,然后根据他们的选择显示不同的视图控制器。
解决方案:
假设你使用LocationManager,那么在delegate中有个方法是
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
enum {ios
kCLErrorLocationUnknown = 0, // location is currently unknown, but CL will keep trying
kCLErrorDenied, // CL access has been denied (eg, user declined location use)
kCLErrorNetwork, // general, network-related error
kCLErrorHeadingFailure, // heading could not be determined
kCLErrorRegionMonitoringDenied, // Location region monitoring has been denied by the user
kCLErrorRegionMonitoringFailure, // A registered region cannot be monitored
kCLErrorRegionMonitoringSetupDelayed, // CL could not immediately initialize region monitoring
kCLErrorRegionMonitoringResponseDelayed, // While events for this fence will be delivered, delivery will not occur immediately
kCLErrorGeocodeFoundNoResult, // A geocode request yielded no result
kCLErrorGeocodeFoundPartialResult, // A geocode request yielded a partial result
kCLErrorGeocodeCanceled, // A geocode request was cancelled
kCLErrorDeferredFailed, // Deferred mode failed
kCLErrorDeferredNotUpdatingLocation, // Deferred mode failed because location updates disabled or paused
kCLErrorDeferredAccuracyTooLow, // Deferred mode not supported for the requested accuracy
kCLErrorDeferredDistanceFiltered, // Deferred mode does not support distance filters
kCLErrorDeferredCanceled, // Deferred mode request canceled a previous request
};
typedef NSInteger CLError;