2

我尝试让 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];       
        }
    }

先感谢您!

4

1 回答 1

3

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

更改if为:

if([CLLocationManager locationServicesEnabled])

删除!.

于 2010-12-27T16:34:39.853 回答