Пользовательский вид MKUserLocation не перемещается!

Я создал собственный MKAnnotationView для местоположения пользователя:

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation

{

if ([annotation isKindOfClass:[MKUserLocation class]]) {

    if (navStatus == NavStatusHeadingEnabled) {

        if ([annotation isKindOfClass:[MKUserLocation class]]) {

            locationView = [[CustomLocationView alloc] initWithAnnotation:annotation reuseIdentifier:@"locationIdentifier"];
            return locationView;

        }

    }

    return nil;

}

CustomLocationView.h

       - (id)initWithAnnotation:(id <MKAnnotation>)annotation reuseIdentifier:(NSString *)reuseIdentifier
    {
        self = [super initWithAnnotation:annotation reuseIdentifier:reuseIdentifier];
        if (self != nil)
        {


            self.backgroundColor = [UIColor clearColor];
            blueDot = [UIImage imageNamed:@"userLocationDot.png"].CGImage;
            CGImageRetain(blueDot);

            CGPoint blueDotCenter = CGPointMake((self.frame.size.width - (CGImageGetWidth(blueDot) / 2)) / 2, (self.frame.size.height - (CGImageGetHeight(blueDot) / 2)) / 2);

            blueDotLayer = [CALayer layer];
            blueDotLayer.frame = CGRectMake(blueDotCenter.x, blueDotCenter.y , CGImageGetWidth(blueDot) / 2, CGImageGetHeight(blueDot) / 2);
            blueDotLayer.contents = (id)blueDot;
            blueDotLayer.shadowOpacity = 0.4;
            blueDotLayer.shadowColor = [UIColor blackColor].CGColor;
            blueDotLayer.shadowOffset = CGSizeMake(0.4, 0.3);
            blueDotLayer.shadowRadius = 1.0f;

            [self.layer insertSublayer:blueDotLayer above:self.layer];

        }

        return self;
    }

- (void)setAnnotation:(id <MKAnnotation>)annotation
{
    [super setAnnotation:annotation];

    [self setNeedsDisplay];
}





- (void)dealloc {

    [blueDotLayer release];


    [super dealloc];
}

Проблема в том, что он просто остается на том же месте и не перемещается, как синяя точка. Что я делаю не так?

Спасибо Билл.

7
задан Nimrod7 24 April 2011 в 07:51
поделиться