ビューベースの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はライブのサイズ変更のためにより良く機能しているようです –