ios - 如何等到“当前位置”对话框得到回答才能运行方法?

标签 ios objective-c core-location core-bluetooth

根据请求当前位置的基于 iOS 的对话框(如下图所示)的反馈推送 View Controller 的最佳做法是什么?

我正在尝试确定选择是否成功 -> 在流程中继续发送用户或失败 -> 显示一个要求他们允许当前位置的屏幕。

我已经从按下按钮分配 CLLocationManager 的方法调用此方法:

- (void) confirmInfo {


    BOOL locationAllowed = [CLLocationManager locationServicesEnabled];

    if (locationAllowed==NO) {
        // Show the how-to viewcontroller
    } else {
        // Go to the next step onboarding
    }

}

但我不知道如何等到输入从对话框返回来选择向用户显示哪个 VC。

enter image description here

最佳答案

您可以使用委托(delegate)方法,用户将允许或即使用户不允许...从该响应中您可以继续推送弹出消息。

否则,您甚至可以尝试基于 block 的结构来保持流程。 以下链接可以帮助你.. https://github.com/intuit/LocationManager 或者 https://github.com/FuerteInternational/FTLocationManager

INTULocationManager *locMgr = [INTULocationManager sharedInstance];
[locMgr requestLocationWithDesiredAccuracy:INTULocationAccuracyCity
                                   timeout:10.0
                      delayUntilAuthorized:YES  // This parameter is optional, defaults to NO if omitted
                                     block:^(CLLocation *currentLocation, INTULocationAccuracy achievedAccuracy, INTULocationStatus status) {
                                         if (status == INTULocationStatusSuccess) {
                                             // Request succeeded, meaning achievedAccuracy is at least the requested accuracy, and
                                             // currentLocation contains the device's current location.
                                         }
                                         else if (status == INTULocationStatusTimedOut) {
                                             // Wasn't able to locate the user with the requested accuracy within the timeout interval.
                                             // However, currentLocation contains the best location available (if any) as of right now,
                                             // and achievedAccuracy has info on the accuracy/recency of the location in currentLocation.
                                         }
                                         else {
                                             // An error occurred, more info is available by looking at the specific status returned.
                                         }
                                     }];

关于ios - 如何等到“当前位置”对话框得到回答才能运行方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25657974/

相关文章:

objective-c - 在 iOS 设备上的应用程序之间共享文件

iphone - 是否可以通过他在 ios 中的电话号码跟踪用户位置?

ios - 核心运动事件是否与核心位置有关

iphone - 核心位置 : How do I wake my app up when iPhone turned on after significant location change?

ios - 用户是否能够看到正在运行的后台应用程序并将其停止?

ios - 使用 textField 和 textView 让键盘消失

ios - 如何在 GET 请求之外使用变量?

iphone - UIView 内容剪辑不起作用/UIView 调整大小不起作用

ios - 可以在 block 中使用自己的 ivar(而不是使它们成为属性)

ios - 使用 NSData(contentsOfURL : imageUrl) 时内存使用量会增加