I'm trying to create NSTableViewsomething similar to how Things makes its layout.

I guess they use NSTableViewwith a custom pattern NSTableCell- or maybe that NSSegmentedControl. I'm trying to go down the route NSTableCell. I tried to subclass NSTableCellViewand draw a custom cell (all this in the init method for testing);
- (id)init {
self = [super init];
if (self) {
_checkbox = [[NSButton alloc] init];
[_checkbox setButtonType:NSSwitchButton];
_textview = [[NSTextView alloc] init];
[self addSubview:_checkbox];
[self addSubview:_textview];
[self setTranslatesAutoresizingMaskIntoConstraints:NO];
NSDictionary *views = NSDictionaryOfVariableBindings(_checkbox, _textview);
[self addConstraints:
[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[_checkbox]-[_textview]|"
options:0
metrics:nil
views:views]];
}
return self;
}
@end
It seems pretty straightforward, but it actually doesn't work. I get errors regarding restrictions that cannot be met. Is it not possible to use autostart inside a subclass NSTableCellView?
source
share