프로그래밍 방식으로 NSScrollView 내에 NSTableView를 만들지 만, 프레임을 스크롤 뷰로 설정하려고하면 제약 조건 오류가 발생합니다.NSScrollView의 자동 레이아웃 제약
Unable to simultaneously satisfy constraints:
(
"<NSAutoresizingMaskLayoutConstraint:0x107d4ec50 h=--& v=--& V:[NSScrollView:0x10068c570(372.5)]>",
"<NSAutoresizingMaskLayoutConstraint:0x107d4d020 h=-&- v=-&- V:[NSClipView:0x10068d7f0]-(673)-| (Names: '|':NSScrollView:0x10068c570)>",
"<NSAutoresizingMaskLayoutConstraint:0x107d4cfc0 h=-&- v=-&- V:|-(2)-[NSClipView:0x10068d7f0] (Names: '|':NSScrollView:0x10068c570)>"
)
Will attempt to recover by breaking constraint
<NSAutoresizingMaskLayoutConstraint:0x107d4d020 h=-&- v=-&- V:[NSClipView:0x10068d7f0]-(673)-| (Names: '|':NSScrollView:0x10068c570)>
Set the NSUserDefault NSConstraintBasedLayoutVisualizeMutuallyExclusiveConstraints to YES to have -[NSWindow visualizeConstraints:] automatically called when this happens. And/or, break on objc_exception_throw to catch this in the debugger.
자동으로 생성되는 것처럼 보입니다.
이
내 생성 코드 (사용 아크) 내가 여기-(void)addColumnsToTable{
NSTableColumn *col = [[NSTableColumn alloc]initWithIdentifier:@"priority"];
[col.headerCell setStringValue:@"priority"];
[col setWidth:10];
[col setMinWidth:1];
[col setMaxWidth:10];
[self.tableView addTableColumn:col];
// col = [[NSTableColumn alloc]initWithIdentifier:@"name"];
// [self.tableView addTableColumn:col];
}
-(void)createTable{
NSTableView *tableView = [[NSTableView alloc]initWithFrame:NSZeroRect];
[tableView setDelegate:self];
[tableView setDataSource:self];
NSScrollView *scrollView = [[NSScrollView alloc]initWithFrame:self.bounds];
[scrollView setBorderType:NSGrooveBorder];
[self addSubview:scrollView];
[scrollView setDocumentView:tableView];
[scrollView setHasVerticalScroller:YES];
[scrollView setAutohidesScrollers:YES];
self.tableView = tableView;
self.scrollView = scrollView;
[self addColumnsToTable];
}
NSView의
서브 클래스 해요되어이 파괴되는 곳 :-(void)setFrame:(NSRect)frameRect{
[super setFrame:frameRect];
[self.scrollView setFrame:self.bounds];
}
이 자동 제약을 해제하는 방법이 있나요?