iOS中的locationServicesEnabled> 4.0始终显示UIAlert

时间:2010-12-27 15:59:23

标签: 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];       
        }
    }

提前谢谢!

1 个答案:

答案 0 :(得分:3)

看起来你的状况是倒退的。它目前说“如果没有启用位置服务,则开始更新其他警报”。

if更改为:

if([CLLocationManager locationServicesEnabled])

删除!