MKMapView is unable to satisfy constraints when it has a zero height constraint attached to it

Originator:Felix.Lisczyk
Number:rdar://33961931 Date Originated:2017/08/18
Status:Closed Resolved:
Product:iOS + SDK / MapKit Product Version:10.3.1 (14E8301)
Classification:Other Bug Reproducible:Always
 
I want to hide a MKMapView dynamically at runtime. For this purpose, I attach a NSLayoutConstraint with a height constant of 0. Every time this constraint gets activated the following warning appears in the console:

---

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:0x6000004816d0 UILayoutGuide:0x60000019e850'Edge Insets'.top == MKMapView:0x7f96b4054c00.top + 8   (active)>",
    "<NSLayoutConstraint:0x600000286680 UILayoutGuide:0x60000019e850'Edge Insets'.bottom == MKMapView:0x7f96b4054c00.bottom - 8   (active)>",
    "<NSLayoutConstraint:0x60800028f0f0 MKMapView:0x7f96b4054c00.height == 0   (active)>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x600000286680 UILayoutGuide:0x60000019e850'Edge Insets'.bottom == MKMapView:0x7f96b4054c00.bottom - 8   (active)>

---

I can prevent this issue by setting the MKMapView's bounds height manually to 0 before activating the constraint.

The issue also occurs when MKMapView is inside a UIStackView and I set the map view's 'hidden' property to 'true'. In this case, UIStackView hides the map view by adding an internal height constraint with a constant of 0.

Comments

This issue is resolved in iOS 11 beta 7.

By Felix.Lisczyk at Aug. 28, 2017, 8:56 a.m. (reply...)

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!