检测ios的用户是否拒绝开启默认位置的实现,该如何处理

检测ios的用户是否拒绝开启默认位置的实现
本帖最后由 ****_Ask 于 2013-01-31 10:52:44 编辑
原问题来自于****问答频道,更多解决方案见:http://ask.****.net/questions/1295
 
原问题描述:
请问一下,检测ios的用户是否拒绝开启默认位置,能实现么?
我需要在实现检测结果,然后根据他们的选择显示不同的视图控制器。
解决方案:
假设你使用LocationManager,那么在delegate中有个方法是
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error


你来检测这个error.code是什么,具体参见apple官方文档Core Location Constants Reference中CLError部分

enum {
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;
ios

------解决方案--------------------
谢谢哦,楼主
------解决方案--------------------
谢谢哦,楼主 
------解决方案--------------------
顶上去,顶上去
------解决方案--------------------
很好,先赚个币再说。
------解决方案--------------------