C H A P T E R 3
If at some point after the child views have been created you want to modify the
contents of the
array and build new child views from it, you can
view method. First, make any changes you desire to the
array, then send your view the
message. All of
the view's current children will be closed and removed. A new set of child views
will then be recreated from the
Also, note that reordering the
array and then calling
is the way to reorder the child views of a
For details on an easy way to create a template dynamically, see "Creating
Templates" (page 3-36).
Using the AddStepView Function
If you need to create a template and add a view yourself at run time, use the
. This function takes two parameters: the parent view to
which you want to add a view, and the template for the view you want to create.
The function returns a reference to the view it creates. Be sure to save this return
value so you can access the view later.
function also adds the template to the parent's
array. This means that the
array needs to be
will fail. See the code in the previous section for an
example of how to ensure that the
array is modifiable.
function doesn't force a redraw when the view is created, so
you must take one of the following actions yourself:
Send the new view a
Send the new view's parent view a
message. This is useful if you're
to create several views and you want to show them all at
the same time.
If you created the view template with the
bit cleared, the new view
will remain hidden and you must send it the
message to make it visible.
This technique is useful if you want the view to appear with an animation effect
(specified in the
slot in the template).
Do not use the
function in a
method--it won't work because that's too early
in the view creation process of the parent for child views to be created. If you are
tempted to do this, you should instead use the second method of dynamic view
creation, in which you add your template to the
array and let the
view system create the view for you.