ビューベースを使用しているときに、選択した行のビューを変更するにはどうすればよいNSTableView
ですか? 具体的には、選択されていない行用の単純な NSView サブクラスと、選択された行用のより複雑な NSView サブクラスが必要です。これにより、行項目に関連付けられたより多くの情報を編集できます。
一例として、Things で編集中のアイテムを展開する方法を以下に示します: http://culturedcode.com/things/
ビューベースを使用しているときに、選択した行のビューを変更するにはどうすればよいNSTableView
ですか? 具体的には、選択されていない行用の単純な NSView サブクラスと、選択された行用のより複雑な NSView サブクラスが必要です。これにより、行項目に関連付けられたより多くの情報を編集できます。
一例として、Things で編集中のアイテムを展開する方法を以下に示します: http://culturedcode.com/things/
私の推測では、行が選択されたときに別の NSTableCellView サブクラスを使用したいと考えています。次のようなことができるはずだと思います:
- (void)tableViewSelectionDidChange:(NSNotification *)notification
{
NSTableView *table = [notification object];
NSIndexSet *allColumns = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, [[table tableColumns] count])];
[table reloadDataForRowIndexes:[table selectedRowIndexes] columnIndexes:allColumns];
}
- (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
{
if ([[tableView selectedRowIndexes] containsIndex:row])
{
// If the row is selected, return an instance of the class for selected views
SelectedTableCellView *selectedView = ...; // Get from makeViewWithIdentifier:
// Set up selectedView
return selectedView;
}
else
{
NonSelectedTableCellView *nonSelectedView = ...; // Get from makeViewWithIdentifier:
// Set up nonSelectedView
return nonSelectedView;
}
}
NSOutlineView
アプリは、選択した行を簡単に展開できるアウトラインビューのみで作成されていると思います...
- (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item
{
if ([item isKindOfClass:[NSDictionary class]])
{
return YES;
}else
{
return NO;
}
}
私はこのように書くと思います..