解决方案 我只需要应用约束以使其工作:
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 文件加载的)未正确显示。
我的意思是:
为什么我的 detailCalloutAccessoryView 被切断了?它应该是这样的:
有什么想法吗?我该如何解决这个问题?
最佳答案
解决方案我只需要应用约束以使其工作。这段代码放在我的 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/