0
我的表格視圖中的每一行都只是說「Table View Cell」。我檢查過我使用的數據源數組,它有55個對象,其中沒有一個具有「Table View Cell」的值。爲什麼我的tableview行不能填充我提供的數據?
@implementation BMAppDelegate
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
self.schemes = [BMSchemeHandler parseSchemeFileToArray];
self.schemeTableView.dataSource=self;
self.schemeTableView.delegate=self;
}
-(id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row{
return [self.schemes objectAtIndex:row];
}
-(NSInteger)numberOfRowsInTableView:(NSTableView *)tableView{
return (self.schemes.count);
}
這裏是我的解決方案...
@implementation BMAppDelegate
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
self.schemes = [BMSchemeHandler parseSchemeFileToArray];
self.schemeTableView.dataSource=self;
self.schemeTableView.delegate=self;
}
-(NSInteger)numberOfRowsInTableView:(NSTableView *)tableView{
return (self.schemes.count);
}
- (NSView *)tableView:(NSTableView *)tableView
viewForTableColumn:(NSTableColumn *)tableColumn
row:(NSInteger)row {
// Retrieve to get the @"MyView" from the pool or,
// if no version is available in the pool, load the Interface Builder version
if([tableColumn.identifier isEqualToString:@"myCell"]){
NSTableCellView* result = [tableView makeViewWithIdentifier:@"myCell" owner:self];
// Set the stringValue of the cell's text field to the nameArray value at row
result.textField.stringValue = [self.schemes objectAtIndex:row];
// Return the result
return result;
}else{
}
return nil;
}
實現viewForTableColumn:行運行良好。謝謝! –