更新#5我想这是赏金时间.即使使用我发布的代码示例,也有100多个视图并且没有人被刺穿.一些声望点怎么样!
更新#4这是一个非常复杂的问题,所以我创建了一个新的基于选项卡的项目,其中包含我的应用程序的部分,我在这里遇到了麻烦.您可以从以下网址下载:http://www.servinitup.net/CustomCalloutAnnotation.zip 随意打开它(需要添加自己的包标识符才能在手机上运行)并玩它,看看你是否可以得到那个darned标注注释随着针移动!
更新#3尝试使setAnnotation成为教程的CalloutMapAnnotationView的公共方法并直接调用它.没有运气.尽管发生了一些奇怪的事情,唯一感动的是标注的小三角形部分.我无法让整个标注移动.
更新#2仍然没有多少运气,但现在一直在寻找以编程方式创建"缩放到缩放"然后立即撤消它的方法,因此用户永远不会看到更改.希望以编程方式执行此操作与手动执行此操作具有相同的效果,并且callout注释将弹回到它的父级.有任何想法吗?
更新#1在这里玩了之后我已经得到了: - 替换self.calloutAnnotation.coordinate = coords;为self.calloutAnnotation.latitude = coords.latitude;self.calloutAnnotation.longitude = coords.longitude;
- 随着更改,如果我稍微捏住地图以在引脚更新后放大或缩小,则标注注释会动画到正确的位置,正好在针.
所以现在我需要弄清楚如何在没有用户实际捏缩放的情况下实现这一点.
原帖
我和其他SO用户一起使用这个非常棒的解决方案来创建自定义标注注释:http: //blog.asolutions.com/2010/09/building-custom-map-annotation-callouts-part-1/
当您使用标准标注(annotationview.canShowCallout = true)并且当位置更新时,引脚在屏幕上移动,标准标注随着引脚一起跟踪,就像它们被锁定在一起一样.
使用上面的自定义标注解决方案时,当我的图钉在位置更新后移动时,标注注释将保留在其原始位置.当然,我想模仿iOS标准,并有自定义标注注释轨道和引脚.
这是我到目前为止的代码,它成功地移动了注释视图,但不是自定义的callout注释视图:
/* core location broadcasts a notification, and my view controller listens to that notification and calls locationManagerDidFindLocation */
- (void)locationManagerDidFindLocation:(NSNotification *)notif {
CLLocation *location = [notif.userInfo objectForKey:@"location"];
CLLocationCoordinate2D coords = [location coordinate];
MKCoordinateSpan span = MKCoordinateSpanMake((5/69), (5/69));
MKCoordinateRegion region = … 我是objective-c中的mapkit新手.我可以在mapview中添加自定义注释.
我需要放置自定义标注视图,如下图所示
.
但我没有得到如何设计这样的标注视图.
我知道我需要在视图中为注释方法添加callout.
- (MKAnnotationView *)mapView:(MKMapView *)map viewForAnnotation:(id <MKAnnotation>)annotation
{
static NSString *AnnotationViewID = @"annotationViewID";
MKAnnotationView *annotationView = (MKAnnotationView *)[mapview dequeueReusableAnnotationViewWithIdentifier:AnnotationViewID];
if (annotationView == nil)
{
annotationView = [[[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:AnnotationViewID] autorelease];
}
annotationView.image = [UIImage imageNamed:@"blue_without_pin.png"];
annotationView.annotation = annotation;
return annotationView;
}
Run Code Online (Sandbox Code Playgroud) 我在mapview iOS6中选择一个引脚时遇到了一个谜

顺便说一句,它在iOS 5中正常工作,我不确定他们在iOS 6的地图中发生了什么变化产生了这个问题.
请注意,当我单击地图时,标注会直接越过引脚并正确显示
任何帮助/线索将不胜感激,
提前致谢
您好我已经陷入了地图上的一种情况,我已设法显示自定义注释.点击注释时,我必须显示包含一些信息和一个按钮的视图.当用户点击按钮时,应显示一个警报.
代码如下
- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view {
if (![view.annotation isKindOfClass:[MKUserLocation class]]) {
POCustomAnnotation *annotation = (POCustomAnnotation *)[view annotation];
UIView *bgview=[[UIView alloc]initWithFrame:CGRectMake(-30, -150,130, 150)];
bgview.backgroundColor=[UIColor grayColor];
UILabel *templbl=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, 130, 120)];
templbl.text=annotation.displayText;
templbl.textAlignment=NSTextAlignmentRight;
templbl.numberOfLines=10;
[bgview addSubview:templbl];
UIButton *tembtn=[UIButton buttonWithType:UIButtonTypeCustom];
[tembtn setTitle:@"More info" forState:UIControlStateNormal];
[tembtn addTarget:self action:@selector(annotationBtnAction:)
forControlEvents:UIControlEventTouchUpInside];
tembtn.backgroundColor=[UIColor grayColor];
tembtn.frame=CGRectMake(0, 121, 130, 30);
[bgview addSubview:tembtn];
[view addSubview:bgview];
} else {
POMapAnnotationView *callout = (POMapAnnotationView *)[[[NSBundle mainBundle]loadNibNamed:@"POMapAnnotationView" owner:self options:nil] objectAtIndex:0];
view.canShowCallout = NO;
CGRect calloutViewFrame = callout.frame;
calloutViewFrame.origin = CGPointMake(-calloutViewFrame.size.width …Run Code Online (Sandbox Code Playgroud)