iphone - iOS >4.0 中的 locationServicesEnabled 始终显示 UIAlert

标签 iphone mapkit cllocationmanager locationmanager

我尝试让 locationServicesEnabled 功能正常工作...但是无论 locationServices 是否启用,我的 UIAlert 都会显示!我怎样才能让它正常工作?

 @synthesize locationServicesEnabled
    -(void)viewDidLoad {
     [super viewDidLoad];

     if(![CLLocationManager locationServicesEnabled]) {
      self.locationManager = [[[CLLocationManager alloc] init] autorelease];
      locationManager.delegate = self;
      locationManager.desiredAccuracy = kCLLocationAccuracyBest;
      [locationManager startUpdatingLocation];
        } else {
            [[[[UIAlertView alloc] initWithTitle:@"Location services." 
                                         message:@"Location services are disabled." 
                                        delegate:nil 
                               cancelButtonTitle:@"OK" 
                               otherButtonTitles:nil] autorelease] show];       
        }
    }

提前谢谢您!

最佳答案

看来你的情况已经倒退了。目前它显示“如果未启用位置服务,则开始更新其他警报”。

if更改为:

if([CLLocationManager locationServicesEnabled])

删除!

关于iphone - iOS >4.0 中的 locationServicesEnabled 始终显示 UIAlert,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4539919/

相关文章:

android - 移动开发 - 原生 VS 跨平台 VS JavaScript

iphone - UINavigationBar自定义背景问题

ios - swift 2.0 : How do I specify which Annotation is pressed when having more then one Annotation? 市场

IOS-didFailWithError : Error Domain=kCLErrorDomain Code=0.(kCLErrorDomain 错误 0。)”

iphone - CLLocationManager 如何在飞行模式开启时获取位置

ios - 如何在ios中制作文字阴影

iphone - 如何判断iphone第一次加载应用?

swift - 如何在同一区域附近设置多个注释

ios - 无法将点击手势识别器添加到 SwiftUI MKMapView UIViewRepresentable

Swift、MapKit、CLLocation如何避开收费公路