我尝试让 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/