[iOS] NamedGuides should be added to the window. |
||
Issue descriptionThere have been several bugs that arose from NamedGuide usage stemming from not being able to tell when a view is within the same hierarchy as the NamedGuides. One example is Issue 907485, where we were unable to detect when a view was removed from the NamedGuide's hierarchy, leading to a crash. Issue 907485 can be fixed by listening to window changes as a trigger to check whether the NamedGuides are in the view's current hierarchy. This fix works because the view is always either A) not in a window, or B) in a window and a subview of BVC, so listening to window changes are effectively the same as listening to being added/removed from BVC's hierarchy. This is not guaranteed, however, as NamedGuides are not explicitly guaranteed to be added to the BVC. One solution to make NamedGuide usage more robust is to explicitly add them directly to the window, so any UIViews that uses NamedGuides for their layout can use |-didMoveToWindow| as a reliable trigger for NamedGuide updates.
,
Dec 6
,
Dec 6
Hmm that's a good point about having to deactivate/reactivate the constraints every time the window changes. Maybe we could create an NSLayoutConstraint subclass specific to NamedGuides such that this behavior is handled internally by the constraint? I'm not sure how feasible it is to fix this by requiring all constraints that use NamedGuides to be recreated rather than deactivated/reactivated. It'd be difficult to enforce this in code, and relying on "best practices" for NamedGuide usage allows for future bugs like this to occur. |
||
►
Sign in to add a comment |
||
Comment 1 by gambard@chromium.org
, Dec 6