Hi Quincey, I saw Kyle Sluder’s post some time ago, but it’s quite old and I’m not sure how relevant it is now. My complaint about scroll views is not that they don’t work, but that they’re confusing and I struggle each time I use them. My initial email was an attempt to summarise what I’ve discovered (so that it might be easier next time) and perhaps elicit helpful insights.
One of the things I’ve discovered is that you don’t have to fight the auto-resizing constraints that Apple adds by default. If you’re using actual constraints further down the view hierarchy, it’s much better to add explicit constraints to the “document” view - in which case the autoresize mask is removed and you don’t need to worry about it. Or if you’re adding a view from a nib, you can turn off autoresizing for this view (in IB or in code). Placeholder constraints are useful in situations where IB doesn’t know about constraints that are added in code or in other views. The solution that I have is working fine. I’ve used similar solutions in the past, and they’ve also worked fine - on different macOSes and with different versions of Xcode. The “problem” is that it seems like I have to go through a process of trial and error to rediscover this solution on each occasion, so I’ve been trying to consolidate my experience. What I’m doing in a nutshell is: 1. Add explicit constraints to the “document” view so that the leading and trailing edges are pinned to the superview (i.e. the clip view). This prevents horizontal scrolling. This is similar to using an autoresize mask with the horizontal lines/arrows turned on, except that autoresizing will also generate additional constraints that conflict with explicit constraints in subviews. 2. Add placeholder constraints for the top and bottom edges. These aren’t needed as actual constraints (because the height of the “document" view is determined by a subview that is added in code) but they’re required in order to keep IB from complaining about missing constraints. Thanks to your emails, I do now have a clearer idea of how to use constraints between the clip view and “document” view. I’d figured out by trial and error that I should use a placeholder constraint for the bottom edge (to allow scrolling), but your comments also prompted me to use a placeholder constraint for the top edge. This "makes sense" because you don’t logically want the top edge to be pinned to the clip view. (Still, it’s curious that everything still works if the top constraint is not a placeholder.) Jeremy _______________________________________________ Cocoa-dev mailing list ([email protected]) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [email protected]
