Re: Creating a criteria search view
Re: Creating a criteria search view
- Subject: Re: Creating a criteria search view
- From: "Louis C. Sacha" <email@hidden>
- Date: Wed, 21 Apr 2004 00:53:51 -0700
Hello...
Nope :) In this particular context, above and below refer to stacked
positions, not the two dimensional relationship between the views (it
refers to the z axis, if you understand what I mean by that). For
example, if you have a pile of papers on your desk, page 1 is above
page 2, page 5 is below page 4, ect... (assuming the pages are in
order).
Using addSubview: is usually sufficient unless you have subviews
which are supposed to overlap (which is generally discouraged). What
you want is the pages spread out on the desk, which requires changing
the frame of the subview instead. I'm not sure exactly why your code
isn't working, but a couple suggestions:
1) Try setting the frame origin before you add the view as a subview.
2) Don't refer to the existing frame origin of the unarchived view
when you are setting the frame origin (although using the height is
okay). You should probably use the bounds rectangle of the superview
as a reference (or 0.0 if that is appropriate).
NSRect bounds = [searchCriteriaSuperview bounds];
for (c = 0; c < totalCriteria; c++)
{
NSView *row = (NSView *)[NSUnarchiver
unarchiveObjectWith
Data:archRow];
[row setFrameOrigin:NSMakePoint(bounds.origin.x,
bounds.origin.y + c * rowHeight)];
[searchCriteriaSuperview addSubview:row];
}
Another seperate issue, which might be caused by cutting and pasting
code into the message for the list, but if you are running the code
as it is in the email, it appears that you only remove one
searchCriteriaView and then create the full number you need. For
example, if you have 2 criteria views and you tried to use this
version of the code to increase the number to 3, you would actually
end up with 4 (2-1+3). You could use the subviews method on the
superview of your criteria views to get an array of them so that you
can remove all of the views.
Hope that helps,
Louis
Trying again... My specific question is: is it reasonable to assume
that addSubview:positioned:relativeTo: will automatically position
the new subview below the specified one without my needing to do any
more? I added the setFrameOrigin because I wasn't seeing this
behaviour but even that makes no difference. The views appear to be
placed behind each other.
- Steve
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.