Constraints relating an NSBox's subviews to itself should transfer to the contentView
| Originator: | jalkut | ||
| Number: | rdar://15525179 | Date Originated: | 11/21/2013 |
| Status: | Open | Resolved: | |
| Product: | Developer Tools | Product Version: | 5.0.2 |
| Classification: | Serious Bug | Reproducible: | Always |
Summary: When designing a user interface in Interface Builder, it is impossible to relate the content of a box precisely to the conceptual borders of the box's content. Because constraints added to subviews of a box will relate to the box itself and not to its dynamically created contentView, they will be off by an unpredictable amount depending on the size of the box's title area, border width, etc. To alleviate this I think one of two approaches should be taken (possibly both): 1. IB should expose the contentView of an NSBox as a visual component of the view hierarchy. This would be comparable to the manner in which IB shows e.g. the NSClipView that is a necessary component of a scroll view's hierarchy. By exposing the contentView to IB designers, the constraints for box subviews could be appropriately designated between the view and its ultimate superview. 2. NSBox should arrange that when it creates the contentView and transfers the box's subviews into the contentView, any pertinent constraints linking the subviews to the box itself should be replaced with constraints that link the subviews to the contentView. Obviously there is some risk here of undoing an constraint that was intentionally meant to link to the box itself, but I think that would be uncommon in practice. To workaround the bug, constraints on an NSBox's subviews must be removed at runtime and replaced manually with constraints that relate the views to the contentView. Steps to Reproduce: 1. Open the attached sample project. 2. Build and run. In each of the two boxes that appear in the sample project window, the subview of the box as been constrained to completely fill the superview. Expected Results: Each of the two boxes should show a colored content view whose 8-point border is completely visible within the contentView of the box. Actual Results: The top box exhibits the problematic behavior: the constraint between the subview and the box causes the top of the subview to be clipped behind the title area of the box. The bottom box exhibits the corrected behavior, having removed the constraints dynamically at runtime and reinstalled constraints that link the subview to the contentView instead.
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!