On Tue, Dec 11, 2012, at 10:34 AM, Chuck Soper wrote: > > Never? The documentation for > setTranslatesAutoresizingMaskIntoConstraints: > says, "You should call this method yourself for programmatically created > views." This means that programmatically created views cannot be added to > NSSplitView, NSTableCellView and other common container views.
Please read the Cocoa Autolayout Release Notes <http://developer.apple.com/library/mac/#releasenotes/UserExperience/RNAutomaticLayout/_index.html%23//apple_ref/doc/uid/TP40010631>: > The principle circumstance in which you should not call > setTranslatesAutoresizingMaskIntoConstraints: is when you are not the person > who specifies a view’s relation to its container. For example, an > NSTableRowView instance is placed by NSTableView. It might do this by > allowing the autoresizing mask to be translated into constraints, or it might > not. This is a private implementation detail. Other views on which you should > not call setTranslatesAutoresizingMaskIntoConstraints: include an > NSTableCellView, a subview of NSSplitView, an NSTabViewItem’s view, or the > content view of an NSPopover, NSWindow, or NSBox. > > The outcome of this is that I need to avoid NSSplitView, NSTableCellView, > etc. so that I can load (and reload) a custom view from a nib file. > Instead, I'll need to implement my own split views using constraints and > not rely on NSSplitView. I must call > setTranslatesAutoresizingMaskIntoConstraints:NO for my programmatically > created views. You are misinterpreting the documentation. It is NOT a requirement to call -setTranslatesAutoresizingMaskIntoConstraints: on programatically-created views. The documentation is simply calling out a case when you would call this method from code because IB didn't already call it for you when you added the view to a view hierarchy in an auto-layout-aware nib. > > >On 10.8, NSSplitView should be calling > >-setTranslatesAutoresizingMaskIntoConstraints: already. > > > >> And, that NSSplitView won't add constraints that conflict with my > >> subviews? > > > >This should be the case. > > NSTableView does add constraints that conflict with my subviews. Is > NSSplitView different? And did that difference happen in 10.8? NSTableView always sets the frame of its row and cell views using the values returned by -frameOfCellAtColumn:row: and the like. If you add constraints that conflict with those values, you will have a conflict. You cannot use constraints to define the frame of a cell or row view in an NSTableView. You can use constraints to position the contents of that view, however. I do it all the time. > > >> > >> The "Cocoa Auto Layout Guide" says not to call > >> setTranslatesAutoresizingMaskIntoConstraints:NO for subviews of > >> NSSplitView, but I think that's for 10.7 and the statement is no longer > >> true for 10.8. Is that correct? > > > >See above. > > Being able to call setTranslatesAutoresizingMaskIntoConstraints:NO for > subviews of > NSSplitView would allow me to add programmatically created views to an > NSSplitView instance. I think that NSSplitView in 10.8 works better with > subviews with constraints (than 10.7), but I haven't been able to confirm > this from the documentation. As above, you are assuming you need to call -setTranslatesAutoresizingMaskIntoConstraints: where no such requirement exists. --Kyle Sluder _______________________________________________ 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