简体   繁体   中英

How to satisfy no-margin inside a NSTableCellView using Cocoa Auto Layout

I have created a custom NSTableCellView with some subviews aligned using Cocoa Auto Layout. Nothing bad at all except when I placed the NSOutlineView (using the custom NSTableCellView) inside a NSSplitView.

The problem occurs when I have tried to collapse the splitView where the custom NSTableCellView fails all the time to satisfy the horizontal constraint, in details the margin specified by the "-" character between _imageView and _textField does not to be zero length.

The horizontal constraint looks like:

[self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[_imageView]-[_textField]|"
                                                                 options:NSLayoutAttributeNotAnAttribute
                                                                 metrics:nil
                                                                   views:NSDictionaryOfVariableBindings(_imageView, _textField)]];

Does someone have an idea how to make the margin between the _imageView and _textField flexible?

You could use H:|[_imageView]-(<=8)-[_textField]| to make the margin flexible. Or you could keep a hold of the constraints and remove them when you need to collapse the split view

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM