Hey guys, Thank you all for your useful answers, Chuck, Laurent and Quincey, you guys rock! Fixed the issue.
Best – Toby On Jul 12, 2012, at 2:24 AM, Quincey Morris wrote: > On Jul 11, 2012, at 15:06 , TJ wrote: > >> The problem here is that I don't have any idea where and how to get and set >> the frame of the cell. As you can see during the creation of NSTableCellView >> I'm basically using an NSZeroRect because [cellView frame] is nil. I >> subclassed NSTableCellView and added a red color for the background in order >> to see if the NSZeroRect gets automatically updated to the current cell rect >> - it does work. But it just doesn't make sense to create a subview of >> NSTableCellView with a zero-frame... is there a method inside >> NSTableCellView I should subclass and position the NSTextField? Or is it >> common to get the frame inside -viewForTableColumn and adjusting the text >> field there? What's the way Apple had in mind concerning programmatically >> creating a view-based NSTableView? I couldn't find a lot of information on >> this, the demo video on developer.apple.com directly uses an NSTextField as >> the return cell-view but my view needs to be more complex than that. I am >> pretty sure I just missed something very important here. ;-) > > The cell view creation occurs earlier than the point where the cell view's > geometry (including its frame) is configured for the row where it's going to > be used. (Note that you're only creating the view if there isn't one to > reuse, and the re-used one will have the "wrong" frame from wherever it was > last used.) > > You never set the frame yourself. The table view does that. > > In a circumstance like this, you can create the view with any frame you want, > because it will be re-sized and re-positioned later. The only real > consideration is that, depending on the intended subviews, you may choose > *not* to make the view very small, because autoresizing of subviews of a view > that's too small to contain them may produce undesirable results. > > So, use an empty frame rect, or a 100 x 100 frame rect or a 1000 x 1000 frame > rect or whatever is convenient for the purpose of initially creating the view. > >> And my second question is - is it possible to create a cell view which is >> bigger than one row, thus it's overlaying other rows (I'm not customizing my >> table view to death, I have a good reason for cell views being positioned >> over several rows). > > I dunno, but I doubt that it works. The table view re-uses cell views that > are scrolled out of the content view, and I suspect it bases this on the row > height, not the row's cell view's frame rect. In addition, I'd imagine that > overlapping rows might mess up row animations. Lastly, your view is going to > be resized by the table view itself, so your attempt to re-size is might be > frustrated anyway. > > > P.S. Here's a documentation reference: > > > https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/TableView/PopulatingView-TablesProgrammatically/PopulatingView-TablesProgrammatically.html#//apple_ref/doc/uid/10000026i-CH14-SW5 > > which has sample code similar to yours. Note the comment that says, "the > height of the frame is not really relevant, the row-height will modify the > height". > _______________________________________________ Cocoa-dev mailing list ([email protected]) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [email protected]
