Remove custom views from NSOutlineView
Remove custom views from NSOutlineView
- Subject: Remove custom views from NSOutlineView
- From: Daniel Price <email@hidden>
- Date: Sun, 2 Dec 2007 18:42:30 +0000
I'm having some problems with NSOutlineView. I'm trying to create a
'filters list'. Basically, the outline view lists a filters, each of
which is a custom NSCell which loads a view from the NIB. Each filter
has one 'child' and a single level of expansion so that when you
expand a filter in the list, the child row contains another view from
the NIB, this time displaying the actual controls etc associated with
that filter type. So we have two distinct views: a 'header view' which
contains the filter name and a delete button, and a 'content view'
which contains it's widgets.
Filter 1 - header view (collapsed)
Filter 2 - header view (expanded)
- content view
I'm using the standard data source/delegate methods and I got that
working. The problem is the views are disappearing when there are
multiple rows and are not removed when a row is collapsed. I'm aware
of the removeFromSuperviewWithoutNeedingDisplay method (swiped from
joar.com's examples, which inspired me) and have used it similarly in
NSTableViews when calling reloadData thus
while ([[mTableView subviews] count] > 0) {
[[[mTableView subviews] lastObject]
removeFromSuperviewWithoutNeedingDisplay];
}
But I can't get it working for the outline view. I tried using the
outlineViewItemDidCollapse notification to instruct each view to
remove itself when collapsed but still no joy.
- (void)outlineViewItemWillCollapse:(NSNotification *)notification
{
id item = [[notification userInfo] valueForKey: @"NSObject"];
else if ( [item isKindOfClass: [Filter class]] ) {
[[item view] removeFromSuperviewWithoutNeedingDisplay];
}
}
I've not found anything on the web. Any suggestions would be most
helpful.
_______________________________________________
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