我尝试使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];
}
}
提前谢谢!
答案 0 :(得分:3)
看起来你的状况是倒退的。它目前说“如果没有启用位置服务,则开始更新其他警报”。
将if
更改为:
if([CLLocationManager locationServicesEnabled])
删除!
。