동적 뷰가있는 뷰 기반 NSTableView
은 테이블 뷰 크기가 변경 될 때 행의 크기가 조정되지 않습니다. 행 높이가 테이블 뷰의 너비에서 파생 될 때 문제가됩니다 (열을 채우고 줄 크기를 확장하는 텍스트 블록을 생각하십시오). 뷰 기반 NSTableView에서 행의 크기를 올바르게 조정
NSTableView
를 얻기 위해 노력했지만 작은 성공을 경험 한 :
- 내가
enumerateAvailableRowViewsUsingBlock:
, 보이지 않는 행의 일부를 쿼리 만 보이는 행의 크기를 조정하는 경우 크기가 조정되지 않으므로 사용자가 스크롤하여이 행을 표시 할 때 이전 높이로 표시됩니다. - 모든 행의 크기를 조정하면 많은 행이있을 때 눈에 띄게 느려집니다 (1.8Ghz i7 MacBook Air에서 각 창 크기를 1000 행으로 조정 한 후 약 1 초 지연).
아무도 도와 드릴 수 있습니까?
나는 테이블 뷰의 크기 변화를 감지 곳입니다 - 테이블 뷰의 위임에 :
다음 반면- (void)tableViewColumnDidResize:(NSNotification *)aNotification
{
NSTableView* aTableView = aNotification.object;
if (aTableView == self.messagesView) {
// coalesce all column resize notifications into one -- calls messagesViewDidResize: below
NSNotification* repostNotification = [NSNotification notificationWithName:BSMessageViewDidResizeNotification object:self];
[[NSNotificationQueue defaultQueue] enqueueNotification:repostNotification postingStyle:NSPostWhenIdle];
}
}
은 가시 행 크기가 조정받을 위에 게시 된 통지의 핸들러
-(void)messagesViewDidResize:(NSNotification *)notification
{
NSTableView* messagesView = self.messagesView;
NSMutableIndexSet* visibleIndexes = [NSMutableIndexSet new];
[messagesView enumerateAvailableRowViewsUsingBlock:^(NSTableRowView *rowView, NSInteger row) {
if (row >= 0) {
[visibleIndexes addIndex:row];
}
}];
[messagesView noteHeightOfRowsWithIndexesChanged:visibleIndexes];
}
모든 행의 크기를 조정 대안 구현은 다음과 같습니다
-(void)messagesViewDidResize:(NSNotification *)notification
{
NSTableView* messagesView = self.messagesView;
NSIndexSet indexes = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0,messagesView.numberOfRows)];
[messagesView noteHeightOfRowsWithIndexesChanged:indexes];
}
참고 :이 질문은 다소 View-based NSTableView with rows that have dynamic heights과 관련되어 있지만 테이블보기의 크기 변경에 응답하는 데 더 중점을 둡니다.
나를 위해 사용자가 크기 조정을 완료하고 행 높이를 다시 조정할 때까지 기다렸습니다. – adib
분명히 스크롤 뷰 내용보기는 '[self.scrollView.contentView setPostsBoundsChangedNotifications : YES]를 호출 한 후에도 변경 알림을 게시하지 않습니다. – adib
NSViewFrameDidChangNotification은 NSViewFrameDidChangNotification에 대한 라이브 크기 조정을 위해 –