Refresh MKAnnotationView on a MKMapView

前端 未结 7 464
天涯浪人
天涯浪人 2021-01-31 09:27

I\'d like to a-synchronically load images for my custom MKAnnotationView; I\'m already using the EGOImageView-framework (it goes very well with UITableViews), but I fail to make

相关标签:
7条回答
  • 2021-01-31 10:06

    This worked for me

    #import "EGOImageView.h"
    
    - (MKAnnotationView *)mapView:(MKMapView *)theMapView viewForAnnotation:(id <MKAnnotation>)annotation
    {
        //ENTER_METHOD;    
        if([annotation isKindOfClass:[MKUserLocation class]]) return nil;  
        MKPinAnnotationView *annView;
    
        static NSString *reuseIdentifier = @"reusedAnnView";
        annView = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:reuseIdentifier];
        annView.canShowCallout = YES;
        annView.calloutOffset = CGPointMake(-5.0f, 0.0f);
        annView.opaque = NO;
        annView.image = [[UIImage imageNamed:@"tempImage.png"] retain];
    
        YourModel *p = annotation; // make this conform to <MKAnnotation>
        EGOImageView *egoIV = [[EGOImageView alloc] initWithPlaceholderImage:[UIImage imageNamed:@"tempImage.png"]];
        [egoIV setDelegate:self];
        egoIV.imageURL = [NSURL URLWithString:p.theUrlToDownloadFrom];
        [annView addSubview:egoIV];
        [egoIV release];
    
    
        return [annView autorelease];
    }
    
    0 讨论(0)
提交回复
热议问题