У меня проблема с перекрывающимися рядами при прокрутке в таблице. Данные отображаются правильно, но при прокрутке вниз текст в строках перекрывается текстом из других строк.NSTableView перекрывающиеся строки при прокрутке
Вот код для создания NStableView
:
-(void)addTableAt:(NSRect)rect withIdentifier:(NSString *)identifier withIndex:(int) index
{
// Get the table
if ([identifier isEqualToString:@"table_0"]) {
// The view
view = [[NSView alloc] initWithFrame:NSMakeRect(0.0, 0.0, rect.size.width,rect.size.height)];
}
// The ScrollView for the table
NSScrollView *tableScrollView = [[NSScrollView alloc] initWithFrame:NSMakeRect(index*rect.size.width, 0.0, rect.size.width, rect.size.height)];
// The table view
NSTableView *tableView = [[NSTableView alloc] initWithFrame:NSMakeRect(index*rect.size.width, 0.0, rect.size.width, rect.size.height)];
[tableView setIdentifier:identifier];
[tableView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
[tableView setHeaderView:nil];
// Set up the right click menu
NSMenu *theMenu = [[NSMenu alloc] initWithTitle:@"Contextual Menu"];
NSString *menuString = [NSString stringWithFormat:@"%@_%d", @"table", index];
NSMenuItem *menuItem = [theMenu insertItemWithTitle:@"Submit to Restore" action:@selector(fileRestore:) keyEquivalent:menuString atIndex:0];
[menuItem setEnabled:YES];
[menuItem setTarget:self];
[tableView setMenu:theMenu];
// Set the column
NSTableColumn *column =[[NSTableColumn alloc]initWithIdentifier:identifier];
[column.headerCell setTitle:@"Header Title"];
[column setWidth:245];
// Add the column tot he table
[tableView addTableColumn:column];
// Set the source and the delegate
[tableView setDataSource:self];
[tableView setDelegate:self];
[tableView setAllowsMultipleSelection: YES];
// Add the table to the scroll view
[tableScrollView setDocumentView:tableView];
// Create the view and the table scroll view
[view setFrame:NSMakeRect(0.0, 0.0, (index+1)*rect.size.width, rect.size.height)];
[view addSubview:tableScrollView];
// Set the view into the main scroll view
[main_scrollview setDocumentView:view];
// Add the main scroll view to the main view
[main_view addSubview:main_scrollview];
[main_view setNeedsDisplay:YES];
}
Любые идеи о том, как это исправить?
Спасибо, что было очень полезно. – frangieh