iphone - xcode ios objective-c mkmapview : compare MKMapView span

标签 iphone objective-c ios xcode mkmapview

如何比较 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 是一个结构,它有两个值 latitudeDeltalongitudeDelta,看起来像这样,

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/

相关文章:

ios - UIView 底边模式

ios - MPMoviePlayerController 缩略图图像 AtTime : timeOption: giving empty UIImage

ios - 在应用程序中处理数据请求,最佳实践

iphone - 如何在Cocoa Objective-C中创建类别类

ios - Touch ID API - 仅使用非 Touch ID 手机的 PIN 码?

iphone如何在频繁加载图片时管理内存

objective-c - 有效地从 NSMutableArray 中删除索引集

iphone - animationDidStop 用于组动画

iphone - CLLocation 的准确度有多准确?

iphone - NSUserDefaults 值更改