简体   繁体   English

如何处理“警报”中针对位置服务弹出的“取消”按钮

[英]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.

相关问题 处理取消位置服务警报 - Handling cancel of the location services alert 弹出Safari / Chrome上的“取消”按钮以在App Store中打开以弹出 - Handle Cancel button on Safari/Chrome for Open in App Store pop up iOS:从设置中关闭位置服务后,是否可以通过设置按钮禁用默认警报弹出窗口 - iOS: Can I disable the default alert pop-up with settings button when location services is turned off from settings 如何在自动化过程中处理警报哪个弹出窗口? - How to handle alert which pop-up during Automation? 处理位置服务警报的 UITest 案例 - UITest cases to handle with location services alert iOS - 使用“设置”和“取消”按钮打开“位置服务” - “如何捕获取消”按钮单击 - iOS - Turn on Location Services with Settings and Cancel buttons -How do I Capture Cancel button click 当我的应用程序中的位置服务关闭时,如何显示包含设置+取消按钮的UIAlertView? - How to present UIAlertView which contains Settings + Cancel button when location services are turned off in my app? SwiftUI | 如何在警报 window 中隐藏取消按钮? - SwiftUI | How to hide cancel button in alert window? 如何处理facebook对话框apprequest的取消按钮? - How handle cancel button of facebook dialog apprequest? 如何在iOS应用中撤消/取消/注销“位置服务” - How to Revoke / Cancel / Unregister “Location Services” inside of the iOS app
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM