Re: View-based NSTableView question
Re: View-based NSTableView question
- Subject: Re: View-based NSTableView question
- From: Chuck Soper <email@hidden>
- Date: Wed, 11 Jul 2012 16:30:57 -0700
- Thread-topic: View-based NSTableView question
This isn't an answer but, if you didn't find it, the Table View
Programming Guide has been quite useful for me:
https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Tab
leView/
You can find it with the following link, then filtering the results by
unchecking the boxes on the left that don't apply to your situation.
https://developer.apple.com/search/index.php?q=NSTableView
Chuck
On 7/11/12 3:06 PM, "TJ" <email@hidden> wrote:
>Hey guys,
>
>I'm trying to replace my old cell-based NSTableView system with the new
>10.7+ view-based one without using Xcode's Interface Builder for the
>table view and column creation.
>What I am doing now is creating an NSTableCellView inside NSTableView's
>delegate method [-NSTableView tableView:viewForTableColumn:row:]:
>
>- (NSView *)tableView:(NSOutlineView *)aTableView
>viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
>{
> NSString *identifier = [tableColumn identifier];
> NSString *stringValue = [self tableView:aTableView
>objectValueForTableColumn:tableColumn row:row];
> NSTableCellView *cellView = [aTableView
>makeViewWithIdentifier:identifier owner:self];
> if (cellView == nil)
> {
> // Create cell view
> cellView = [[[NSTableCellView alloc] initWithFrame:[cellView frame]]
>autorelease];
> cellView.identifier = identifier;
> // Create text field
> NSTextField *textField = [[[NSTextField alloc] initWithFrame:[cellView
>frame]] autorelease];
> [textField setIdentifier:identifier];
> [textField setBordered:NO];
> [textField setDrawsBackground:NO];
> [textField setStringValue: stringValue];
> cellView.textField = textField;
> [cellView addSubview:textField];
> return cellView:
> }
>
> [cellView.textField stringValue];
> return cellView;
>}
>
>The problem here is that I don't have any idea where and how to get and
>set the frame of the cell. As you can see during the creation of
>NSTableCellView I'm basically using an NSZeroRect because [cellView
>frame] is nil. I subclassed NSTableCellView and added a red color for the
>background in order to see if the NSZeroRect gets automatically updated
>to the current cell rect - it does work. But it just doesn't make sense
>to create a subview of NSTableCellView with a zero-frame... is there a
>method inside NSTableCellView I should subclass and position the
>NSTextField? Or is it common to get the frame inside -viewForTableColumn
>and adjusting the text field there? What's the way Apple had in mind
>concerning programmatically creating a view-based NSTableView? I couldn't
>find a lot of information on this, the demo video on developer.apple.com
>directly uses an NSTextField as the return cell-view but my view needs to
>be more complex than that. I am pretty sure I just missed something very
>important here. ;-) And my second question is - is it possible to create
>a cell view which is bigger than one row, thus it's overlaying other rows
>(I'm not customizing my table view to death, I have a good reason for
>cell views being positioned over several rows).
>
>Thank you very much in advance!
>_______________________________________________
>
>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:
>
>This email sent to email@hidden
_______________________________________________
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:
This email sent to email@hidden