Re: sortSubviewsUsingFunction Question?
Re: sortSubviewsUsingFunction Question?
- Subject: Re: sortSubviewsUsingFunction Question?
- From: Wilhelm Phillips <email@hidden>
- Date: Mon, 18 Oct 2004 11:29:11 -0700
Thanks Brendan,
That example was exactly what I needed. I was a little confused about
the need for the separate function and how to set it up.
Though I do know the desired order of the subviews, for some reason
they are arbitrarily ordered on build. I layer them in the desired
order in IB - (an unbordered NSPopupButton directly overlapping an
NSImage), but they don't appear in the same order when I build. This
strangeness may be caused by my main custom NSView. Using the
sortSubviewsUsingFunction works perfectly to ensure the correct order
of the subviews. I believe I read in the archives a couple of others
having the same ordering issues with overlapping subviews.
And thanks for your comments on properly describing problems.
Will
On Oct 17, 2004, at 5:37 PM, Brendan Younger wrote:
sortSubviewsUsingFunction: takes a function as a parameter, not just a
list of parameters. Here's how to call it:
int my_great_sorting_function(id view1, id view2, void* context) {
// do some wonderful sorting here and return NSOrderedAscending or
NSOrderedDescending
}
// Later on....
[mainView sortSubviewsUsingFunction:my_great_sorting_function
context:nil];
That should work. Note how the parameter list for
my_great_sorting_function() matches the definition of
sortSubviewsUsingFunction. Also, you shouldn't say "crashes" to
describe compiling problems. Crashing is when the running application
quits unexpectedly, whereas failing to compile is a different problem.
However, since you obviously already know the order of the views, you
can simply place them into mainView in the correct order the first
time.
Brendan Younger
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden