【问题标题】:MKPinAnnotationView not movingMKPinAnnotationView 不动
【发布时间】:2011-08-23 07:48:36
【问题描述】:

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

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

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

    - (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;
}

【问题讨论】:

    标签: iphone objective-c ios4 mkpinannotationview google-geocoding-api


    【解决方案1】:
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-06-28
    • 2013-01-15
    • 2012-12-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多