views:

87

answers:

1

Hi there.

I'm doing something with cocoa which I think is a bit complicate for a beginner like me. I tried a few things, but I admit I need some theory first, because I would like to understand exactly the meaning of this concepts.

I see that every NSView and every class that subclasses it has one thing called frame, and one called bounds. They both have a size with width and height and an origin.

I have an NSView with an NSTableView inside of it. I have the size of a row from the table view, and I would like to set the height of both NSView and NSTableView equal to rows*rowSize, in a way that the group NSView+subviews is automatically resized when an object is added or removed to and from the data source of the Table View.

I made some experiments, but I did end a bit confused about frame, bounds, sizes and so on. I don't know what I should change and how.

Can you please give me an hint about what bounds and frame basically are, and how can I achieve that magic resizing?

Thank you for your replies in advance. Best regards,

—Albé

A: 

The difference between frame and bounds is covered very nicely in the View Programming Guide (under View Geometry).

You'll also want to peruse the NSView Class Reference, where you'll find some handy notifications, such as NSViewFrameDidChangeNotification and handy methods such as -setPostsFrameChangedNotifications:.

Joshua Nozzi