我有一个MKMapView
约300高,它折叠在两个其他视图之间,只是像折叠视图时通常那样上下动画高度。MKMapView与零高度约束挣扎 - edgeInsets的地图视图?
@IBOutlet var heightMap: NSLayoutConstraint!
@IBOutlet var theMap: MKMapView!
当视图启动它是高度为零..
override func viewDidLoad() {
super.viewDidLoad()
..
heightMap.constant = 0
}
有一股真气警告...
[LayoutConstraints] Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want.
Try this:
(1) look at each constraint and try to figure out which you don't expect;
(2) find the code that added the unwanted constraint or constraints and fix it.
(
"<NSLayoutConstraint:0x6080000904f0 MKMapView:0x7fe6b3000600.height == 0 (active)>",
"<NSLayoutConstraint:0x608000093a60 UILayoutGuide:0x60800018fd80'Edge Insets'.top == MKMapView:0x7fe6b3000600.top + 8 (active)>",
"<NSLayoutConstraint:0x608000093b50 UILayoutGuide:0x60800018fd80'Edge Insets'.bottom == MKMapView:0x7fe6b3000600.bottom (active)>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x608000093b50 UILayoutGuide:0x60800018fd80'Edge Insets'.bottom == MKMapView:0x7fe6b3000600.bottom (active)>
注意,这似乎是挣扎带有“edgeInsets”或可能的“Edge Insets”(带空格!)顶部和底部,
'Edge Insets'.top == MKMapView:0x7fe6b3000600.top + 8
'Edge Insets'.bottom == MKMapView:0x7fe6b3000600.bottom
地图视图有一个只读属性.alignmentRectInsets
(其实当我打印了这一点,不管它是什么,它是零反正..
let ari = theMap.alignmentRectInsets
print("wth \(ari)")
> wth UIEdgeInsets(top: 0.0, left: 0.0, bottom: 0.0, right: 0.0)
)
我甚至无法在MKMapView上找到任何关于“边缘插入”的信息,这里的交易是什么?
我仔细检查了未安装的约束和常见问题。
如果你给高度constriant,无需底部和顶部的布局约束。尝试删除其中的一个。 – MBN
hi @MBN - 不,我没有添加奇怪的'Edge Insets'.top和'Edge Insets'.bottom约束。这些似乎是由MKMapKit本身添加的。 (所有“我的”约束都是完美的)。 – Fattie
这是令人难以置信的没有人知道这一点! – Fattie