我已经用我的自定义注释 View 替换了 mapview
中用户位置的蓝点,如何使我的自定义注释像默认蓝点一样跟随用户的位置?当我用我的自定义注释替换蓝点或简单地创建 MKAnnoationView
时,它只是停止随用户移动。在 mapview 的 viewForAnnotation
委托(delegate)方法中,我正在做
pinView = [[MKAnnotationView alloc]
initWithAnnotation:annotation reuseIdentifier:defaultPinID];
pinView.image = [UIImage imageNamed:@"newgreen2.png"];
[mapView.userLocation setTitle:@"I am here"];
return pinView
这是显示带有 newgreen2 图像的图钉,但它没有移动,但如果我在此委托(delegate)方法中返回 nil,默认情况下会出现蓝点,它会随着用户的位置移动。是否有任何技巧可以为我的自定义注释 View 模仿用户位置的默认蓝点行为?我注意到 viewForAnnotation
只被调用一次,然后蓝点自动开始跟踪用户位置。
有什么方法可以让我的注释 View 跟随用户的位置吗?
最佳答案
我们有两个链接可能对您有帮助
How to change MKMapView's user-location blue dot to an image of choice?
和
Avoid flicker when moving annotations in a MKMapView on iPhone
请检查一下。
关于iphone - 移动自定义注释以显示用户位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16121058/