> On 19 Jan 2018, at 22:15, Quincey Morris > <quinceymor...@rivergatesoftware.com> wrote: > >> Interface Builder complains if I don’t also add vertical constraints, so >> I’ve done that, but made the bottom constraint into a placeholder (“Remove >> at build time”). Your email suggests that I can also make the top constraint >> into a placeholder. I’ve tried that now, and it seems to work fine. It also >> makes sense :) > > Using placeholder constraints makes no sense to me. > > First of all, you need to understand that in current versions of Xcode, IB > translates those resizing control arrows into constraints for you, unless you > add *explicit* constraints that it regards as overriding this “free” > translation. This means that those arrows are *not necessarily* honored. If > you’re getting messages about missing constraints, then that means you’ve > added some subview constraints that prevent the document view height > constraint from being inferred.
Once you add explicit constraints, IB turns off autoresizing altogether. The red arrows/lines disappear - there’s nothing there to be honoured or not honoured. In my case, IB doesn’t know about the “document" height because it’s determined by a subview that is in a separate nib. That’s why I need to use placeholder constraints (otherwise IB complains about missing constraints). There are several subviews, and they are swapped in and out at runtime. > — You don’t want IB to provide default constraints on the document view. You > should probably write code to remove any existing constraints from the > document view before you swap in new subviews. (Even if you turn off all the > arrows in the IB resize control, it’s not obvious to me that IB won’t add a > height constraint anyway.) You don’t need to turn off the red arrows/lines because they disappear as soon as you add explicit constraints. Without autoresizing, IB doesn’t provide any default constraints. I don’t think you should ever have to remove default constraints in code - you should turn off autoresizing (in IB or in code) to prevent the default constraints from being created in the first place. I think I mentioned previously that constraints are added to the subviews at run time - and, yes, they are removed and recreated when subviews are swapped. It is the subview that determines the width of the “document” view, so the horizontal (explicit) constraints pinning the “document” view to its superview are required. They perform the same task that the horizontal red arrows/lines do with autoresizing (prevent horizontal scrolling). I can’t use autoresizing here because it will create additional constraints that generate conflicts with subview constraints. Jeremy _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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 arch...@mail-archive.com