默认显示当前位置注释 [英] Show current position annotation by default

查看:28
本文介绍了默认显示当前位置注释的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 mapkit 中显示了当前位置注释(蓝点).粘贴蓝点后显示注释,如何在默认情况下显示注释?,当我启动视图时?不用敲针.

I have an current location annotation (blue dot) showing in mapkit. Annotation shows after taping the blue dot, how can I have the annotation showing by default?, when I start the view? whit out tapping the pin.

 - (void)mapView:(MKMapView *)mv didAddAnnotationViews:(NSArray *)views {
    for(MKAnnotationView *annotationView in views) {
        if(annotationView.annotation == mv.userLocation) {

            self.mapView.userLocation.title= @"Current";
            self.mapView.userLocation.subtitle= @"Location";

            MKCoordinateRegion region;
            MKCoordinateSpan span;

            span.latitudeDelta=0.002;
            span.longitudeDelta=0.002; 

            CLLocationCoordinate2D location=mv.userLocation.coordinate;

            region.span=span;
            region.center=location;

            [mv setRegion:region animated:YES];
            [mv regionThatFits:region];

        }
    }

}

推荐答案

在那种情况下,selectAnnotation 应该可以工作,不是吗?过一会儿就执行Selector.

In that case, selectAnnotation should work, wouldn't it? Just performSelector after a small time.

.... 与之前相同的代码,但插入:

.... same code as before but insert this:

            id annotation = annotationView.annotation;
            [self performSelector:@selector(selectUserLocation:) withObject:annotation afterDelay:0.1f];
        }
    }
}

- (void)selectUserLocation:(id)annotation{
    [self.mapView selectAnnotation:annotation animated:YES];
}

这篇关于默认显示当前位置注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆