在地图底部显示视图

胡安乔

当我在地图中选择mkannotation时,我正在寻找一种显示视图的解决方案。在图像中:

在此处输入图片说明

如果选择了mkannotation,则会在底部显示该视图。我有办法,但我不知道这是否是最好的。它只是在地图下显示视图,就像普通视图的子视图一样,但是我看到的问题是它在地图上方,隐藏了其中的一部分,而且我不知道如何检测用户单击了映射以隐藏配置文件的视图。

提前致谢

编辑1.使用此代码,我得到错误,如果修复它,则将.view添加到错误中,这些错误消失了,但是当我选择mkannotation时,它什么也没有出现。

在此处输入图片说明

第一次创建i YourViewController.xib,然后在您的mapviewcontroller中使用以下代码:

- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view {
    if(![view.annotation isKindOfClass:[MKUserLocation class]]) {
        YourViewController *calloutView = (YourViewController *)[[[NSBundle mainBundle] loadNibNamed:@"YourViewController" owner:self options:nil] objectAtIndex:0];
        CGRect calloutViewFrame = calloutView.frame;
        calloutViewFrame.origin = CGPointMake(-calloutViewFrame.size.width/2 + 15, -calloutViewFrame.size.height);
        calloutView.frame = calloutViewFrame;

        [calloutView.calloutLabel setText:[(locationAnnotation*)[view annotation] title]];
        [calloutView.CallDattabel setText:[(locationAnnotation*)[view annotation] subtitle]];
        [calloutView.status setText:[(locationAnnotation*)[view annotation] status]];
        [calloutView.ImageSate setImage:[(locationAnnotation*)[view annotation] image ]];
        [view addSubview:calloutView];
    }

}
-(void)mapView:(MKMapView *)mapView didDeselectAnnotationView:(MKAnnotationView *)view {
    for (UIView *subview in view.subviews ){
        [subview removeFromSuperview];
    }
}

我希望这段代码对您有用

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章