Inconsistent Today Widget behavior breaks subview's height constraints

前端 未结 1 1667
长发绾君心
长发绾君心 2021-01-23 03:24

This question is related to another question I just posted on Stackoverflow:
Layout Constraint Conflicts in Default Today Widget

I added a Today Extension as a targe

相关标签:
1条回答
  • 2021-01-23 03:52

    Try avoiding the use of pins.

    For positioning, rely on aligning your view to the superview's leading, trailing, top, or bottom edges.

    For sizing, try setting your view to have equal heights or widths with the superview. And adjusting the multiplier as needed.

    This solved auto layout inconsistencies I was experiencing in a Today Widget.

    Updated w/ screenshot:

    See above, I am using the align menu (not the pin menu). I select both the view I am trying to constrain, along with the all encasing superview, and tell the prior to share (or, align with) trailing and bottom edges.

    I know this is not how Apple may demonstrate it, however it is a workaround that avoids the bugs that occur when using pins with Today Widgets.

    Update #2 - And here is all the constraints (including height and width):

    The bug must be related to the inferred sizing of a view that is entirely pinned, because when I set the height and width of my view to be relative to its superview (rather than having it be inferred), the bug does not occur.

    0 讨论(0)
提交回复
热议问题