首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >MKPinAnnotationView不移动

MKPinAnnotationView不移动
EN

Stack Overflow用户
提问于 2011-08-23 15:48:36
回答 1查看 1K关注 0票数 0

我在这里浏览了一些关于MKPinAnnotationView引脚、子类等的链接,但不是全部。我在网上做了一些简单的教程,当我认为我可以用教程中的知识开始我的应用程序时,我错了。:(

在我的教程文件中,我设法做了一个简单的MKPinAnnotationView *引脚。设置其属性,如canShowCallOut = YESdraggable = YES。我可以将引脚拖到任何我想要的位置,并显示其放置的位置。

但是当我创建我的新应用程序时,我又做了同样的事情。但是大头针不动,是不是我做错了什么?

代码语言:javascript
复制
    - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation{

    if([annotation isKindOfClass:[CustomPlacemark class]])
    {
        MKPinAnnotationView *newAnnotation = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:[annotation title]];
        newAnnotation.pinColor = MKPinAnnotationColorGreen;
        newAnnotation.animatesDrop = YES; 
        newAnnotation.canShowCallout = YES; // shows the black label when the pin is tapped
        newAnnotation.draggable = YES;
//      newAnnotation.enabled = YES;
        newAnnotation.tag = tag;
        NSLog(@"%@ %@", [annotation title], [annotation subtitle]);
        UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
        [rightButton addTarget:self
                        action:@selector(showDetails:)
              forControlEvents:UIControlEventTouchUpInside];
        newAnnotation.rightCalloutAccessoryView = rightButton;

        NSLog(@"Created annotation at: %f %f", ((CustomPlacemark*)annotation).coordinate.latitude, ((CustomPlacemark*)annotation).coordinate.longitude);

        [newAnnotation addObserver:self
                        forKeyPath:@"selected"
                           options:NSKeyValueObservingOptionNew
                           context:@"GMAP_ANNOTATION_SELECTED"];

        [newAnnotation autorelease];
        tag++;
        NSLog(@"ååååååååå %@", appDelegate.fml);
        return newAnnotation;
    }

    return nil;
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-11-09 23:45:59

瞧一瞧

http://digdog.tumblr.com/post/252784277/mapkit-annotation-drag-and-drop-with-callout-info

我也在寻找同样的问题。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/7157777

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档