根据请求当前位置的基于 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。
最佳答案
您可以使用委托(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/