iphone - 当我们单击我的自定义注释图钉时,自定义标注 View 未显示在 View 中心(iphone)

标签 iphone ios objective-c

enter image description here

当我们单击自定义注释图钉时,标注 View 不会显示在 View 中心,而是显示一半在 View 中,其余显示在 View 之外。请帮助我。
提前致谢

    CGSize const kMultiRowCalloutCellSize = {300,140};

    - (id)initWithAnnotation:(id<MultiRowAnnotationProtocol>)annotation reuseIdentifier:(NSString *)reuseIdentifier onCalloutAccessoryTapped:(MultiRowAccessoryTappedBlock)block {
    self = [super initWithAnnotation:(id<MKAnnotation>)annotation reuseIdentifier:reuseIdentifier];
    if (self) {
        self.contentHeight = 80.0;
        _yShadowOffset = 6;
        self.offsetFromParent = CGPointMake(78, -14); //this works for MKPinAnnotationView
        self.enabled = NO;
        self.backgroundColor = [UIColor clearColor];
        self.cellInsetX = 15;
        self.cellOffsetY = 10;
        self.onCalloutAccessoryTapped = block;
        [self setTitleWithAnnotation:annotation];
        [self setCalloutCellsWithAnnotation:annotation];
    }
    return self;
}

最佳答案

annotationView.centerOffset = CGPointMake( annotationView.centerOffset.x + annotationView.image.size.width/2, annotationView.centerOffset.y - annotationView.image.size.height/2 );

在下面提到的委托(delegate)方法中添加这些行。
- (MKAnnotationView *)mapView:(MKMapView *)theMapView viewForAnnotation:(id <MKAnnotation>)annotation

关于iphone - 当我们单击我的自定义注释图钉时,自定义标注 View 未显示在 View 中心(iphone),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18584442/

相关文章:

iphone - HmacSHA256 objective-c 加密

ios - 按下按钮时如何显示事件卡

ios - 如何在 iOS 上绘制烛台图表?

ios - Swift 3 : db. 执行不使用获取路径使用 Bundle.main.path 运行

ios - 如何为 Data swift 添加扩展?

ios - 如何将弹出序列分配给摇动 Action ?

objective-c - (目标)C 中的垃圾邮件检测

ios - 标签栏图标显示不正确

iphone - Amazon S3 getDate() API 调用?

iOS 刷新 JSON 表