vedo questo è una vecchia questione, ma la risposta è quella di utilizzare una vista basata NSTableView quindi implementare tableView:. viewForTableColumn: fila :.
questo è il codice basato su come Lo faccio. Non è stato compilato in Xcode.
-(NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
NSTableCellView *cell = nil;
// get your row from your array of objects.
// determine if it's a section heading or not.
SomeClass *someObject = [self.myObjects objectAtIndex:row];
if (someObject.isSectionHeading) {
cell = [tableView makeViewWithIdentifier:@"HeaderCell" owner:self];
cell.textField.objectValue = someObject.headingName;
} else {
cell = [tableView makeViewWithIdentifier:@"DataCell" owner:self];
cell.textField.objectValue = someObject.rowValue;
}
return cell;
}
E anche tableView: isGroupRow metterà uno sfondo grigio sui vostri titoli delle sezioni
-(BOOL)tableView:(NSTableView *)tableView isGroupRow:(NSInteger)row {
BOOL isGroup = NO;
// Choose some way to set isGroup to YES or NO depending on your records.
return isGroup;
}
Assicurarsi in Interface Builder aver impostato gli identificatori per le NSTableCellViews a "HeaderCell" e "DataCell". O usa i nomi che vuoi. Finché corrisponde al tuo codice. Puoi avere quante di queste cellule vuoi.
Se si crea una sottoclasse di NSTableCellView, è possibile aggiungere facilmente campi di testo, caselle di controllo, immagini, ecc. Alla vista e impostare i relativi valori di conseguenza.
fonte
2013-10-09 02:28:57
Prova questo: sotto le tabelle complesse tableviews https://developer.apple.com/library/mac/samplecode/TableViewPlayground/Introduction/Intro.html – johndpope