检测ios的用户是否拒绝开启默认位置的实现

问答小助手 2013-01-31 10:51:50
加精
原问题来自于CSDN问答频道,更多解决方案见:http://ask.csdn.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;
...全文
2024 42 打赏 收藏 转发到动态 举报
写回复
用AI写文章
42 条回复
切换为时间正序
请发表友善的回复…
发表回复
4301g 2013-02-17
  • 打赏
  • 举报
回复
能自己定制的机子,更显彰个性,实现起来比较难。
luohongqiang159 2013-02-17
  • 打赏
  • 举报
回复
谢谢了楼主了。。。
owuHuaRou1 2013-02-15
  • 打赏
  • 举报
回复
具体的还是不懂哈
lhw7791086 2013-02-15
  • 打赏
  • 举报
回复
学习了!
oKeXiLiao 2013-02-14
  • 打赏
  • 举报
回复
qq450452364 2013-02-08
  • 打赏
  • 举报
回复
真的( ^_^ )不错嘛 支持
三月廿二 2013-02-08
  • 打赏
  • 举报
回复
谢谢哦,楼主
gmkeys 2013-02-05
  • 打赏
  • 举报
回复
要做高手 首先就要和高手切磋 学习。。。
zhucejiaru 2013-02-04
  • 打赏
  • 举报
回复
很好呢!!!学习!!!
chenqiang605 2013-02-04
  • 打赏
  • 举报
回复
真是牛人啊 高手
z15281877925 2013-02-03
  • 打赏
  • 举报
回复
学习了 ,,,,,
panda8899a 2013-02-02
  • 打赏
  • 举报
回复
太给力了,顶
luck_W 2013-02-01
  • 打赏
  • 举报
回复
来学习下,谢谢
bdkjhw 2013-02-01
  • 打赏
  • 举报
回复
不错,学习学习
mbugaifc 2013-02-01
  • 打赏
  • 举报
回复
youhao1999 2013-02-01
  • 打赏
  • 举报
回复
路过帮顶。。。。
forMuYuZuoBGeng 2013-02-01
  • 打赏
  • 举报
回复
还不错不错..
hg2980986 2013-02-01
  • 打赏
  • 举报
回复
wenbaobb 2013-02-01
  • 打赏
  • 举报
回复
谢谢。。非常有用。。
QQ11QQ112 2013-02-01
  • 打赏
  • 举报
回复
GOODAA
加载更多回复(11)

29,028

社区成员

发帖
与我相关
我的任务
社区描述
主要讨论与iOS相关的软件和技术
社区管理员
  • iOS
  • 大熊猫侯佩
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧