Reputation: 1069
(Shown on 10.10, but reproduced on 10.7 and above)
I've got a Mac menu bar application that starts by loading an NSOutlineView and populating a few view-based cells. Upon selecting the cell the NSOutlineView is hidden, and a new NSTableView (TicketViewController) is presented. The custom NSTableViewCell (CommentComposeCellView) contains a NSTextView and a custom NSView (CommentComposeFooterView) that contains an NSImageView and an NSButton. The NSTableViewCell and custom NSView both have Autolayout constraints so that they should match the size of the window they're contained in. However, when resizing the window the custom NSView does not resize until the window's edge touches the custom NSView.
-(void)outlineViewSelectionDidChange:(NSNotification *)notification{
if ([self.outlineView selectedRow] != -1) {
id clickedItem = [self.outlineView itemAtRow:[self.outlineView selectedRow]];
if ([clickedItem isKindOfClass:[Request class]]){
[self.ticketViewController displayRequest:clickedItem];
[self.scrollView setHidden:YES];
NSView *contentView = [self.window contentView];
[[self.ticketViewController view] setFrame:[contentView bounds]];
[[self.ticketViewController view] setTranslatesAutoresizingMaskIntoConstraints:NO];
[contentView addSubview:[self.ticketViewController view]];
NSView *ticketView = [self.ticketViewController view];
NSDictionary *views = NSDictionaryOfVariableBindings(ticketView);
[contentView addConstraints:
[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[ticketView]|"
options:0
metrics:nil
views:views]];
[contentView addConstraints:
[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[ticketView]|"
options:0
metrics:nil
views:views]];
}
}
}
Upvotes: 1
Views: 673
Reputation: 1069
Added
[tableColumn setWidth:self.view.superview.frame.size.width]
to
- (NSView *)tableView:(NSTableView *)tableView
viewForTableColumn:(NSTableColumn *)tableColumn
row:(NSInteger)row
Upvotes: 1