如何处理“取消”弹出警报按钮以获取位置服务 [英] How to handle "Cancel" button on Alert pop up for Location services

查看:90
本文介绍了如何处理“取消”弹出警报按钮以获取位置服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在应用程序中使用位置服务。当我在打开位置服务的情况下运行该应用程序时,一切都非常完美。但是,如果我在全球范围内关闭位置信息服务,然后返回该应用。它弹出一个对话框,说打开定位服务以允许您确定位置,并带有两个按钮设置和取消。

I am using location services in my application. When I run the application with location services ON, everything is perfect. But, if I turn the Location services OFF globally, and come back to the app. It gives me a pop up saying "Turn on Location services to allow to determine your location" with two buttons "Settings" and "Cancel".

如果我点击设置 ,它将我带到设置应用程序(符合预期)。但是,如果我点击取消,则什么也不会发生。我的应用无法获取事件,它冻结,等待发生的事情。如果之后我触发了其他事件,该事件使用当前位置,则它会授权失败,并且应用会变得正常。

If I tap on Settings, it takes me to Settings app (as expected). But If I tap on "Cancel" nothing happens. My app can't get the event and it freezes, waiting for something to happen. If I fire some other event after that, which uses current location, then it gets authorisation failed, and app becomes normal.

要处理此行为,我想检测触摸取消按钮上的事件。有没有办法做到这一点。因为我认为此弹出窗口是由OS处理的,而不是由SDK处理的。

To handle this behaviour I want to detect the touch event on "Cancel" button. Is there any way to do that. Because I think this pop is handled by OS and not the SDK.

如果我错了,请纠正我。

Correct me if I am wrong.

推荐答案

在这里可以检测取消按钮上的触摸事件:

This is where to detect the touch event on "Cancel" button:

- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error{

}

可能是您的实现导致冻结(而不是iOS)。
尝试并使用此空实现只是为了确保...

Probably, Your implementation of it, causes the freezes (And not the iOS). Try and use this empty implementation just to make sure...

这篇关于如何处理“取消”弹出警报按钮以获取位置服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆