为什么我的 MapKit 标注视图这么小,没有显示它需要显示的所有内容?
Why is my MapKit callout view so small and not showing everything it needs to show?
解决方案 我只需要应用约束即可使其工作:
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 集成,终于让我的应用程序显示我的自定义标注视图,但由于某种原因,它很小并且没有显示它应该显示的所有内容......标题显示正常,但自定义 "detailCalloutAccessoryView"(从 custom-made .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)
解决方案 我只需要应用约束即可使其工作:
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 集成,终于让我的应用程序显示我的自定义标注视图,但由于某种原因,它很小并且没有显示它应该显示的所有内容......标题显示正常,但自定义 "detailCalloutAccessoryView"(从 custom-made .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)