0

小问题,我在地图视图上有一些注释。有时当它们彼此非常靠近时它们往往会重叠,这没关系,但是当我触摸它们时,它们会切换它们的图层位置。那些在后面的现在在前面,反之亦然。

所以我检查了我的 didSelectAnnotation 函数,但该函数中实际上没有代码,所以它不可能是它。

我想不出还有什么可能导致它。

你知道如何修复它,这样它就不会改变图层位置?

这是我的 viewForAnnotation 代码:

annImg = [[szAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"current"];


        szPointAnnotation *pointAnnotation = annotation;
        if (appDelegate.homePage || ([pointAnnotation.tag intValue] >= 10000))
        {
            annImg.canShowCallout = NO;
            annImg.backgroundColor = [UIColor clearColor];
            annImg.frame = CGRectMake(0, /*0*/-78, 70, /*78*/156);



            UIImageView *currentUserPictureView = [[UIImageView alloc] initWithFrame:CGRectMake(5, 5, 60, 60)];

            int newTag = [pointAnnotation.tag intValue]-10000;
            UIImage *currentUserPicture;
            if ([pointAnnotation.tag intValue] >= 10000) {
                currentUserPicture = [UIImage imageWithData:[usersData getKeyForIndexWithKey:@"UserImageData" forIndex:newTag]];
            }else{
                currentUserPicture = [UIImage imageWithData:[usersData getKeyForIndexWithKey:@"UserImageData" forIndex:[pointAnnotation.tag intValue]]];
            }


            currentUserPictureView.image = currentUserPicture;
            userLocationButton = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 70, 78)];
            [userLocationButton setBackgroundImage:[UIImage imageNamed:@"pin.png"] forState:UIControlStateNormal];
            [userLocationButton addTarget:self action:@selector(centerOnUser:) forControlEvents:UIControlEventTouchUpInside];

            if ([pointAnnotation.tag intValue] >= 10000) {
                userLocationButton.tag = newTag;
            }else{
                userLocationButton.tag = [pointAnnotation.tag intValue];
            }


            [userLocationButton setBackgroundColor:[UIColor clearColor]];
            [annImg addSubview:userLocationButton];
            [userLocationButton addSubview:currentUserPictureView];


            [userLocationButton release];
            [currentUserPictureView release];
            [currentUserPicture release];
        }
4

0 回答 0