1

My today widget uses nested stackviews to lay itself out. However, there is slight movement / unintentional resizing when the window is dragged and also when users interact with the view:

enter image description here

The stackview is simply pinned to all four sides of the super view:

enter image description here

I'm not sure if I'm missing something specific to Today Widgets, or possibly UIStackview that is causing this movement to occur.

vikzilla
  • 3,998
  • 6
  • 36
  • 57
  • 2
    From what I understand there's a huge bug in Apple's layout process for Today Widgets. No matter how simple the layouts were that I created in the storyboard (or in code), containing only a single label or a single button, there were ALWAYS inconsistencies that would have worked flawless inside the app itself. See http://stackoverflow.com/questions/37010292/inconsistent-today-widget-behavior-breaks-subviews-height-constraints and http://stackoverflow.com/questions/37009679/layout-constraint-conflicts-in-default-today-widget. – Mischa May 04 '16 at 22:03
  • 1
    We ended up computing the size of EVERY single subview and setting a height constraint with the computed value for each of the views. Another approach would be not to use Autolayout for the Today Widget at all. I know, it's both brute force methods but we've really tried everything else and there were always issues with regular Autolayout. – Mischa May 04 '16 at 22:08

1 Answers1

1

I worked around this by avoiding the use of pins on my view (i.e. pinning it 0 points from any side of its super view).

Rather, I rely on other types of constraints. For example, setting my view to share trailing edges or leading edges with its superview, rather than pinning it 0 points to either side of the superview.

Also handy is using equal widths w/ an adjusted multiplier for more flexibility.

Without any pins, the view no longer jerks / resizes unexpectedly. I recommend testing on a device, as it seems to sometimes slip up on the simulator but not on the device.

vikzilla
  • 3,998
  • 6
  • 36
  • 57