I observed a very strange behavior regarding Autolayout in the Today widgets that I just created for my application. Trying to get to the root of the problem, I created a simple new Xcode project (a single-view application) and added Today Extension as a new goal - without even touching it.
When I run Today Extension on my device (iPhone 6s), the first thing that happens is that layout restrictions conflicts are thrown in the console:
2016-05-03 18:17:22.216 TodayExtension[10183:4611907] 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. ( "<_UILayoutSupportConstraint:0x15c665320 V:[_UILayoutGuide:0x15c6657b0(0)]>", "<_UILayoutSupportConstraint:0x15c663890 V:|-(0)-[_UILayoutGuide:0x15c6657b0] (Names: '|':UIView:0x15c6642a0 )>", "<_UILayoutSupportConstraint:0x15c666010 V:[_UILayoutGuide:0x15c666380(0)]>", "<_UILayoutSupportConstraint:0x15c666ed0 _UILayoutGuide:0x15c666380.bottom == UIView:0x15c6642a0.bottom>", "<NSLayoutConstraint:0x15c666b80 V:[_UILayoutGuide:0x15c6657b0]-(NSSpace(8))-[UILabel:0x15c6617c0'Hello World']>", "<NSLayoutConstraint:0x15c666bd0 V:[UILabel:0x15c6617c0'Hello World']-(NSSpace(8))-[_UILayoutGuide:0x15c666380]>", "<NSLayoutConstraint:0x15c552820 'UIView-Encapsulated-Layout-Height' V:[UIView:0x15c6642a0(0)]>" ) Will attempt to recover by breaking constraint <NSLayoutConstraint:0x15c666bd0 V:[UILabel:0x15c6617c0'Hello World']-(NSSpace(8))-[_UILayoutGuide:0x15c666380]>
You will notice that the last of the restrictions in the list is UIView-Encapsulated-Layout-Height , which forces the screen to a height of 0. I checked and realized that the reference view is a representation of the widget itself. Therefore, for some reason, because of my understanding, the system internally creates a limit on the height of 0 pixels, which conflicts with the presentation settings in Interface Builder. (As you will see, when you create a new extension in Xcode, there is nothing there except the UILabel, which is attached to each side of the widget in the root view.)
I used to claim this was a huge iOS bug, but since this is the default Apple template for creating Today Widgets, I just can't believe it is broken. Any idea what causes this conflicting behavior and how to fix it (correctly)?
What I'm basically trying to achieve with generosity ...
... is to find out if there is a reliable way to use Autolayout in Today Widget without presenting some workarounds and dirty strong> " hacks that you would not use in a regular application. (If you end up adding a lot of restrictions that create fixed frames and do not allow dynamic growth of content, which is not really the idea of ββAutolayout, is it?)
A closely related question is that part of the problem can give a hint:
Inconsistency Today widget behavior violates subtitle height restrictions