Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: NSTableView variable row height and noteHeightOfRowsWithIndexesChanged during live resize
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTableView variable row height and noteHeightOfRowsWithIndexesChanged during live resize




On Apr 23, 2009, at 5:44 PM, Stuart Malin wrote:


On Apr 23, 2009, at 1:18 PM, Corbin Dunn wrote:


On Apr 23, 2009, at 3:37 PM, Stuart Malin wrote:


On Apr 23, 2009, at 12:33 PM, Corbin Dunn wrote:


On Apr 23, 2009, at 2:55 PM, Stuart Malin wrote:

I have an NSTableView with a single column that has a custom cell. During a live resize, I recalculate the row height in the delegate method -tableView:heightForRow: and return the result. However, some rows don't grow larger. I presume I need to call the tableview's -noteHeightOfRowsWithIndexesChanged for each row that has a height change. Is it okay to call this from within the tableView:heightForRow: method?

No, it is not; you'll have to redo your logic, or call it with a range for all rows (probably the easiest thing to do).


Thanks Corbin.

What about from within the tableview delegate method - tableViewColumnDidResize ?

That is fine; note that it is only sent out when the live-resize method ends. Your calculation in -heightForRow: can't depend on the -[tableColumn width], unless you call the -noteHeightXX method more frequently (ie: you'd have to capture when the setWidth: happens by subclassing the table column).


I subclassed the table column and overrode its -setWidth method. When that is invoked, I recalculate the cell heights for *only* the visible rows. I keep track of those rows that change, prepare an index set, and notify the table view with -noteHeightXXX.

Works like a charm!

Question: presently, in the overridden -setWidth, I invoke - noteHeightXXX *before* calling [super setWidth:newWidth] As I said, this works, and seems to me to be the logical ordering of events, but just want to check if I should be calling -noteHeightXXX *after* invoking the super (NSTableColumn) -setWidth.


That should be okay since layout is done lazily (in -viewWillDraw:), but you may want to call the note after calling [super setWidth:]. The reasoning is as follows: if the -noteHeightXX method calls your delegate immediately, and it then recalculates a new row height based on the [column width], then things will be wrong. In practice, this doesn't happen, but there is no reason it couldn't.


corbin


_______________________________________________

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


References: 
 >NSTableView variable row height and noteHeightOfRowsWithIndexesChanged during live resize (From: Stuart Malin <email@hidden>)
 >Re: NSTableView variable row height and noteHeightOfRowsWithIndexesChanged during live resize (From: Corbin Dunn <email@hidden>)
 >Re: NSTableView variable row height and noteHeightOfRowsWithIndexesChanged during live resize (From: Stuart Malin <email@hidden>)
 >Re: NSTableView variable row height and noteHeightOfRowsWithIndexesChanged during live resize (From: Corbin Dunn <email@hidden>)
 >Re: NSTableView variable row height and noteHeightOfRowsWithIndexesChanged during live resize (From: Stuart Malin <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.