如何等待“当前位置”对话框回答以运行方法?

时间:2014-09-04 05:37:13

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

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

我试图在选择成功之后确定 - >在流程中向前发送用户或失败 - >显示一个需要它们允许当前位置的屏幕。

我已经从按钮分配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

2 个答案:

答案 0 :(得分:3)

您可以让Delegate方法用户允许,或者即使用户不允许..并且从该响应中您可以继续推送pop。

否则你甚至可以尝试基于块的结构来维持你的流量。 以下链接可以帮助您.. 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.
                                         }
                                     }];

答案 1 :(得分:0)

首先,创建一个CLLocationManager,然后将控制器设置为其委托,最后调用[self.locationManager startUpdatingLocations];以显示对话框。

然后使用CLLocationManagerDelegate方法确定用户选择的内容:

成功,

– locationManager:didUpdateLocations:

被调用。否则

– locationManager:didFailWithError: