Inconsistency Today widget behavior violates viewing height limits

This question is related to another question I just wrote on Stackoverflow:
Configuring layout restrictions in default widgets today

I added the Today extension as an object for my application, removing the default Hello World shortcut inside the widget and adding a simple UIView . I gave the appearance of yellow and tied it to all the edges of the root view - just as the label was limited. Then I added another restriction on the yellow look to give it a fixed height of 100 pixels.

Widget storyboard

When I run the application (tested on the simulator and device), that the height limit is simply ignored , and the yellow view takes up all the free space right up to the title of the next widget.

When I scroll up the notification center and pull it out again, the view suddenly jumps (it seems like he suddenly β€œsees” his own height limit), leaving a 39-pixel vertical blank space at the bottom of the widget:

First start Subsequent launches

I realized that 39px margin at the bottom is the bottom margin the current widget passed by the defaultMarginInsets parameter in the widgetMarginInsetsForProposedMarginInsets(defaultMarginInsets: UIEdgeInsets) and that I can fix this inconsistent behavior by overriding this method and providing my own field inserts:

 func widgetMarginInsetsForProposedMarginInsets(defaultMarginInsets: UIEdgeInsets) -> UIEdgeInsets { var newInsets = defaultMarginInsets newInsets.bottom = 20 return newInsets } 

However, I would prefer to use the fields provided by the system instead of the fixed values. It seems to me that this is another iOS bug regarding today's widget. It? And if not: how can I fix it?

+1
source share
1 answer

Try to avoid using contacts.

For positioning, rely on aligning your view with the top, end, top, or bottom borders of the top level.

To calibrate, try setting your view to equal height or width with the caption. And adjust the multiplier if necessary.

This resolved the car market inconsistencies that I experienced in Today widgets.

Updated w / screenshot:

enter image description here

See above, I use the align menu ( not the contacts menu). I choose both the view that I am trying to restrain, and the entire list of supervisors, and communicate in front of it the general access (or align ) to the back and bottom edges.

I know that this is not how Apple can demonstrate it, but this workaround avoids errors that occur when using contacts with Today Widgets.

Update No. 2 - And here are all the restrictions (including height and width):

enter image description here

The error should be related to the derived calibration of the view, which is fully fixed, because when I set the height and width of my view relative to my supervisor (instead of being able to output it), the error does not occur.

+1
source

All Articles