【发布时间】:2014-01-08 10:29:52
【问题描述】:
我试图在我的 iOS 应用程序中单击一键获取用户位置。我正在使用下面的代码来启动位置管理器。
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyKilometer;
locationManager.distanceFilter = 1000;
if ([CLLocationManager locationServicesEnabled]) {
[locationManager startUpdatingLocation];
}
else{
UIAlertView *alert= [[UIAlertView alloc]initWithTitle:@"Error" message:@"The location services seems to be disabled from the settings." delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles: nil];
[alert show];
alert= nil;
}
当定位服务打开并且用户点击按钮时,它工作正常并且位置被正确获取。
但是当位置服务关闭并且用户尝试单击按钮时,根据我的代码,他的警报应该显示如上。但在它到达 else 循环之前,iOS 会显示一个系统级别的弹出窗口,如下所示。
在这个系统级别的警报视图之上,我自己的警报视图正在显示。这很令人沮丧。问题是,如果用户取消系统级弹出窗口而不是进入设置并尝试单击按钮,第二次也会发生同样的事情(两个警报场景)。但是,如果用户继续相同的步骤,则系统级警报现在不会显示。这意味着如上所示的系统级弹出窗口仅出现 2 次,之后什么也没有发生。如何处理这种情况。请帮忙。
【问题讨论】:
-
您找到解决方案了吗?
标签: ios cllocationmanager