Although total of the widths should be the same as the width in- between the left edge of the scrollview and the right edge minus the width of the vertical scroller, so although it should see all columns fully, the most right column can't see it whole content unless mouse-wheeling right.

The following code is all I wrote. I put an NSTableView on a window which came in the Cocoa Application template, and an object which was called MyTableSizer.

@interface MyTableSizer : NSObject {
   IBOutlet NSTableView* _tableview;
}
@end

@implementation MyTableSizer
- (void) awakeFromNib
{
   // _tableview is specified in Nib file
float aScrollViewWidth = NSWidth([[_tableview enclosingScrollView] frame]); float aTableViewWidth = aScrollViewWidth - [NSScroller scrollerWidth];
        
   NSLog (@"ScrollView width : %f", aScrollViewWidth);
   NSLog (@"TableView width  : %f", aTableViewWidth);
        
NSEnumerator* enm = [[NSArray arrayWithArray:[_tableview tableColumns]] objectEnumerator];
   id col;
   while (col = [enm nextObject])
        [_tableview removeTableColumn:col];
        
        
   int counter = 5;
   float quotient = aTableViewWidth / counter;
   NSLog (@"Each Column's width: %f", quotient);
   while (counter > 0)
   {
NSTableColumn* col = [[NSTableColumn alloc] initWithIdentifier: [NSString stringWithFormat:@"%d",counter]];
        [col setWidth:quotient];
        [_tableview addTableColumn:[col autorelease]];
        counter--;
   }
}
@end

That's all.

The TableSizer is allocated and initialized in Nib file.


2009-06-29 18:06:47.302 TEST_NSTableColumnWidth[2649:813] ScrollView width : 480.000000 2009-06-29 18:06:47.304 TEST_NSTableColumnWidth[2649:813] TableView width : 465.000000 2009-06-29 18:06:47.305 TEST_NSTableColumnWidth[2649:813] Each Column's width: 93.000000


The log seems to be correct, but actual tableview is actually wider.

What do you think I'm missing?

Any suggestions, advices, and workarounds would be very appreciated. I really need our help.

Thank you,
Norio
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to