[英]How to handle “Cancel” button on Alert pop up for Location services
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.
如果此后我触发了其他某个使用当前位置的事件,那么它将获得授权失败,并且应用程序将变得正常。
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.
因为我认为此弹出窗口是由OS处理的,而不是由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{
}
Probably, Your implementation of it, causes the freezes (And not the iOS). 您的实现可能导致冻结(而不是iOS)。 Try and use this empty implementation just to make sure...
尝试并使用此空实现只是为了确保...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.