如何比较 MKMapView 的当前跨度? 我正在使用以下代码:
- (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated{
if ([[regionsMapView.region.span] doubleValue] < 1.0) {
NSLog(@"SHOW ANNOTATIONS");
}else {
NSLog(@"HIDE ANNOTATIONS");
}
}
但它显示错误如下:
error: expected ':' before ']' token
confused by earlier errors, bailing out
如果我像下面这样使用:
if (regionsMapView.region.span < 1.0) {
NSLog(@"SHOW ANNOTATIONS");
}else {
NSLog(@"HIDE ANNOTATIONS");
}
然后它也显示如下错误:
error: invalid operands to binary < (have 'MKCoordinateSpan' and 'double')
最佳答案
MKCoordinateSpan 是一个结构,它有两个值 latitudeDelta 和 longitudeDelta,看起来像这样,
typedef struct {
CLLocationDegrees latitudeDelta;
CLLocationDegrees longitudeDelta;
} MKCoordinateSpan;
如果你想比较其中的任何值。你应该使用,
if (regionsMapView.region.span.latitudeDelta < 1.0)
或者,
if (regionsMapView.region.span.longitureDelta < 1.0)
关于iphone - xcode ios objective-c mkmapview : compare MKMapView span,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6568134/