• 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
Re: NSView subclassing question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSView subclassing question


  • Subject: Re: NSView subclassing question
  • From: Drew Cunningham <email@hidden>
  • Date: Sun, 24 Mar 2002 01:32:07 -0500

I'm new to cocoa programming, but I'll give my input...

To find out the size of the view myView, use:
NSRect myBounds = [myView bounds];

The size of a view inside a scroll view is not determined by the size of the scroll view.
Set the size of the view inside the scroll view to whatever you want using:
NSSize newSize;
newSize.width = 600; // or a width based upon the inclosing scrollview
newSize.height = 300; // or a height based upon the inclosing scrollview
[myView setFrameSize:newSize];

Obviously, you can use "self" in place of "myView" if you are calling the methods from within your custom view.



I'm about to write my first custom view, but there's a detail about it that I can't seem to figure out from any of the examples. I understand the basics pretty well I think, but all the examples show a view as a subview of,
say, a window's content view. The sample view's size is always determined by the size of the window in this case.

I have a view which needs to display X number of items, and I don't know how big the view will be until I find out how many X is in each case. I'm going to be placing this view inside of a Scroll View so that it can fit
logically inside of a window without making the window weird sizes of course =) Anyway, the thing I don't understand is, when I'm a subview of an NSScrollView (or, really the NSClipView), how do I 'tell' it how big my
view happens to be? What's the proper way to interact with the NSClipView, and how does it interact with me?
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Apple and Developers (was lots of different subjects)
  • Next by Date: Re: Rép : Cocoa's Popularity
  • Previous by thread: NSView subclassing question
  • Next by thread: Apple and Developers (was lots of different subjects)
  • Index(es):
    • Date
    • Thread