How to join NSScrollView and NSTableView programmatically
How to join NSScrollView and NSTableView programmatically
- Subject: How to join NSScrollView and NSTableView programmatically
- From: Jesse Grosjean <email@hidden>
- Date: Wed, 21 Sep 2005 20:51:10 -0400
I feel stupid asking this, but I've just spent the last 4 hours
trying to do something that I though would be very simple. I want to
create a scroll view and embed a table view in it in code. This works
to a point, but for the life of me i can't figure out how to make the
vertical scroller work right. I want the vertical scroller to always
be visible, but it show only show the jellybean drag area when there
are too many rows to fit in the content view.
But for some reason when I run my code the vertical scroller is
always showing showing that the view is scrollable. This has
something to do with the NSTableView's header view, but I don't know
what I need to do to fix it. This code is self contained, you should
be able to just paste, compile, and run to see what I mean:
unsigned int styleMask = NSTitledWindowMask | NSClosableWindowMask |
NSResizableWindowMask;
NSWindow *window = [[NSWindow alloc] initWithContentRect:NSMakeRect
(100, 100, 500, 500) styleMask:styleMask
backing:NSBackingStoreBuffered defer:YES];
NSView *contentView = [window contentView];
NSTableView *tableView = [[[NSTableView alloc] init] autorelease];
NSScrollView *scrollView = [[[NSScrollView alloc] initWithFrame:
[contentView frame]] autorelease];
[scrollView setHasVerticalScroller:YES];
[scrollView setHasHorizontalScroller:NO];
[scrollView setDocumentView:tableView];
[scrollView setAutoresizingMask:NSViewWidthSizable |
NSViewHeightSizable];
[contentView setAutoresizesSubviews:YES];
[contentView addSubview:scrollView];
[window orderFront:nil];
Thanks for any suggestions,
Jesse
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden