Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSTableHeaderView shifting after scrolling



I am reading a csv file into a dictionary and I display the data in a NSTableview.  I created my window in Interface builder and added a NSTableview with one column.  Depending on the needs of the csv file, I add columns to the table.  Here is the code:

-(void) awakeFromNib
{
	NSTableColumn* firstColumn=[theTableView tableColumnWithIdentifier:@"1"];
	[theTableView removeTableColumn:firstColumn];
	int columns=[dataSource noOfColumns];
	if (columns>0) 
	{
		int counter=0;
		while(counter<columns)
		{
				NSString* colName=[NSString stringWithFormat:@"%i",(counter+1)];
				NSTableColumn* newColumn=[[NSTableColumn alloc]initWithIdentifier:colName];
				[newColumn setEditable:NO];
				[newColumn setResizingMask:NSTableColumnNoResizing];
				[[newColumn headerCell]setStringValue:colName];
				[[newColumn dataCell]setAlignment:NSRightTextAlignment];
				[theTableView addTableColumn:newColumn];
				[newColumn release];
				counter++;
		}
	}
	[theTableView setDataSource:dataSource];
	[theTableView setNeedsDisplay:YES];
	[theTableView reloadData];
}

The table displays fine and the data is presented correctly.  However when I scroll, the tableheaderview is shifted over to the right and no longer aligns with the columns.  This problem is corrected when I call:

[[aTableView headerView] setFrameOrigin:NSZeroPoint];

Any ideas about what I am doing wrong?  If this is a bug with cocoa, when would be the time to call 

[[aTableView headerView] setFrameOrigin:NSZeroPoint]; 

so that my table always looks nice?

Thanks

Sarven


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.