【问题标题】:when we clicked on my customized annotation pin, the custom calloutview not displayed in center of the view(iphone)当我们单击我的自定义注释图钉时,自定义标注视图未显示在视图中心(iphone)
【发布时间】:2013-09-03 05:05:28
【问题描述】:

当我们点击自定义注解图钉时,calloutview 不会显示在视图的中心,而是显示一半在视图中,剩下的在视图之外。请帮助我。 提前致谢

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

【问题讨论】:

标签: iphone ios objective-c


【解决方案1】:
annotationView.centerOffset = CGPointMake( annotationView.centerOffset.x + annotationView.image.size.width/2, annotationView.centerOffset.y - annotationView.image.size.height/2 );

在下面提到的委托方法中添加这些行。

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-14
    • 1970-01-01
    • 1970-01-01
    • 2023-03-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多