• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
How to join NSScrollView and NSTableView programmatically
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: How to join NSScrollView and NSTableView programmatically
      • From: email@hidden
    • Re: How to join NSScrollView and NSTableView programmatically
      • From: email@hidden (Stefan Haller)
  • Prev by Date: Re: NSDatePicker Question with NSArrayController and Master/Detail interface
  • Next by Date: Re: How do I create a file name with a "/" in it?
  • Previous by thread: Re: removing NSManagedObject: a conceptual bug in my app
  • Next by thread: Re: How to join NSScrollView and NSTableView programmatically
  • Index(es):
    • Date
    • Thread