检查用户是否允许应用程序使用他们的位置
应用程序第一次尝试获取用户位置时,系统会提示他们“想要使用您当前的位置”,然后他们可以点击“不允许”或“确定”。有什么方法可以查明用户是否点击了“确定”或“不允许”?我试图让 MKMapView 显示用户当前位置,但我想根据用户选择采取不同的操作。
通常您会认为会有一个代表来获取此信息,但似乎没有。
预先感谢您的帮助。
The first time the app tries to get the users location they are prompted with "Would like to use your current location" and they can hit Don't allow or ok. Is there any way to find out if the user has hit ok or don't allow? I'm trying to have the MKMapView show the users current location but I would like to take different actions based on the users selection.
Normally you would think there would be a delegate to get this information but there doesn't seem to be.
Thanks in advance for your help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您第一次获取用户位置的调用将失败,并出现错误,告诉您用户已拒绝位置服务。您的
CLLocationManagerDelegate
方法didFailWithError
将被调用,如下所示。 (常量在CLError.h
中定义)Your first call to get the user's location will fail with an error which tells you the user has denied location services. Your
CLLocationManagerDelegate
methoddidFailWithError
will be called, as below. (The constants are defined inCLError.h
)