ios - 为什么我的 MapKit 标注 View 这么小,没有显示它需要显示的所有内容?

标签 ios swift mapkit

解决方案 我只需要应用约束以使其工作:

let widthConstraint = NSLayoutConstraint(item: customCalloutView, attribute: .Width, relatedBy: .Equal, toItem: nil, attribute: .NotAnAttribute, multiplier: 1, constant: 200)
        customCalloutView.addConstraint(widthConstraint)
        let heightConstraint = NSLayoutConstraint(item: customCalloutView, attribute: .Height, relatedBy: .Equal, toItem: nil, attribute: .NotAnAttribute, multiplier: 1, constant: 200)
        customCalloutView.addConstraint(heightConstraint)

我做了一个 MapKit 集成,最后让我的应用程序显示我的自定义标注 View ,但由于某种原因,它很小并且没有显示它应该显示的所有内容......标题显示正常,但自定义“detailCalloutAccessoryView” (它是从带有一些标签、 ImageView 和按钮的定制 .xib 文件加载的)未正确显示。

我的意思是:

Screenshot of issue

为什么我的 detailCalloutAccessoryView 被切断了?它应该是这样的:

.xib file

有什么想法吗?我该如何解决这个问题?

最佳答案

解决方案我只需要应用约束以使其工作。这段代码放在我的 viewForAnnotation 方法中

let widthConstraint = NSLayoutConstraint(item: customCalloutView, attribute: .Width, relatedBy: .Equal, toItem: nil, attribute: .NotAnAttribute, multiplier: 1, constant: 200)
        customCalloutView.addConstraint(widthConstraint)
        let heightConstraint = NSLayoutConstraint(item: customCalloutView, attribute: .Height, relatedBy: .Equal, toItem: nil, attribute: .NotAnAttribute, multiplier: 1, constant: 200)
        customCalloutView.addConstraint(heightConstraint)

关于ios - 为什么我的 MapKit 标注 View 这么小,没有显示它需要显示的所有内容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35507672/

相关文章:

ios - 如何为SwiftTask框架实现zip功能?

ios - 如何实现不同长宽比的不同 View 布局?

swift - 我在 SpriteKit 上的 scheduledTimer 有问题

ios - 如何通过点击更改 map 注释位置并且仍然能够平移? (包括gif)

ios - NSManagedObject 无法识别的选择器发送到实例

ios - UITabBarController 动画的转换委托(delegate)

ios - 快速滚动时隐藏显示顶 View

ios - 在 Swift map 上的 MKOverlay 中添加模糊 View

ios - 没有得到 "MAP Route"

ios - Xcode 5关闭图标光泽效果的方法