Hello All,
I have a NSTableView with around 70 - 80 rows, each row contain a checkbox, title text and a drop down menu to select data. The problem i am facing is that when i scroll the table it does not scroll smooth. When i remove the NSComboBoxCell it works ok.
Here is the code i used to add NSComboBoxCell -
NSTableColumn* checkColumn = [tblEditData tableColumnWithIdentifier:@"Timer"];
NSCell *aCell = [aTableColumn dataCellForRow:rowIndex];
[aCell setState:3];
NSComboBoxCell *comboBoxCell = [NSComboBoxCell new];
[comboBoxCell addItemWithObjectValue:@"Timer"];
[comboBoxCell addItemWithObjectValue:@"1"];
[comboBoxCell addItemWithObjectValue:@"3"];
[comboBoxCell addItemWithObjectValue:@"6"];
[comboBoxCell addItemWithObjectValue:@"9"];
[comboBoxCell addItemWithObjectValue:@"12"];
[comboBoxCell setStringValue:aDataRow1.timer_val];
[checkColumn setDataCell:comboBoxCell];
return comboBoxCell;
Please advice what should i do to remove the jerky scrolling.
Update here is the full code -
-(id) tableView:(NSTableView *)aTableView
objectValueForTableColumn:(NSTableColumn *)aTableColumn
row:(int)rowIndex
{
NSString *identifier = [aTableColumn identifier];
if (aTableView == tblAddData)
{
AdvancedProtocolDataRow * aDataRow1 = [arrayAddData objectAtIndex:rowIndex];
//NSTableColumn* checkColumn = [tblAddData tableColumnWithIdentifier:@"Title"];
if ([identifier isEqualToString:@"Title"])
{
NSTableColumn* checkColumn = [tblAddData tableColumnWithIdentifier:@"Title"];
//NSCell *aCell = [aTableColumn dataCellForRow:rowIndex];
NSButtonCell* checkBoxCell = [NSButtonCell new];
[checkBoxCell setButtonType:NSSwitchButton];
[checkBoxCell setTitle:aDataRow1.name];
NSString *myString = [checkBoxCell title];
NSMutableParagraphStyle *pStyle = [[NSMutableParagraphStyle alloc] init];
NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:[NSColor whiteColor],
NSForegroundColorAttributeName,
[checkBoxCell font], NSFontAttributeName,
pStyle, NSParagraphStyleAttributeName, nil];
NSAttributedString *atted = [[NSAttributedString alloc] initWithString:myString attributes:dict];
[checkBoxCell setAttributedTitle: atted];
if ([aDataRow1.checkbox_val isEqualToString:@"selected"])
[checkBoxCell setState:NSOnState];
else
[checkBoxCell setState:NSOffState];
[checkColumn setDataCell:checkBoxCell];
return checkBoxCell;
}
else if ([identifier isEqualToString:@"Timer"])
{
/*
NSTableColumn* checkColumn = [tblAddData tableColumnWithIdentifier:@"Timer"];
NSCell *aCell = [aTableColumn dataCellForRow:rowIndex];
[aCell setState:3];
NSComboBoxCell *comboBoxCell = [NSComboBoxCell new];
[comboBoxCell addItemWithObjectValue:@"Timer"];
[comboBoxCell addItemWithObjectValue:@"1"];
[comboBoxCell addItemWithObjectValue:@"3"];
[comboBoxCell addItemWithObjectValue:@"6"];
[comboBoxCell addItemWithObjectValue:@"9"];
[comboBoxCell addItemWithObjectValue:@"12"];
//[comboBoxCell setStringValue:@"Timer"];
[comboBoxCell setStringValue:aDataRow1.timer_val];
[checkColumn setDataCell:comboBoxCell];
return comboBoxCell;
*/
NSTableColumn* checkColumn = [tblAddData tableColumnWithIdentifier:@"Timer"];
NSCell *aCell = [aTableColumn dataCellForRow:rowIndex];
[aCell setState:3];
[comboBoxCell setStringValue:aDataRow1.timer_val];
[checkColumn setDataCell:comboBoxCell];
return comboBoxCell;
}
}
}
Thanks