简体   繁体   English

如何在Swift中选择用户的位置注释

[英]How to select the user's location annotation in Swift

I'm trying to figure out how I would select the user's default location annotation when the map is first displayed to the user. 我试图弄清楚在第一次向用户显示地图时如何选择用户的默认位置注释。 I know I should probably be using this code somehow: 我知道我应该以某种方式使用此代码:

mapView.selectAnnotation(theUsersLocationAnnotation, animated: true)

But where is this 'theUsersLocationAnnotation' Annotation coming from exactly since it's the current location annotation that is normally blue. 但是,“ theUsersLocationAnnotation”注释到底从何而来,因为它通常是蓝色的当前位置注释。 How would I access this to call this on that annotation, so-to-speak? 我要如何访问它才能在该注释上称呼它?

只需使用:

 mapView.selectAnnotation(mapView.userLocation, animated: true)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM