我有一個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